Type | Description | |||
Long | A Long expression that indicates the non-working hours in a day. |
The control supports the following ways of specify the non-working parts for items:
You can select the non-working hours in the following table ( In Internet Explorer, you have to allow running the script on this page ).
24 Hour | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
AM/PM | 11PM | 10PM | 9PM | 8PM | 7PM | 6PM | 5PM | 4PM | 3PM | 2PM | 1PM | 12AM | 11AM | 10AM | 9AM | 8AM | 7AM | 6AM | 5AM | 4AM | 3AM | 2AM | 1AM | 12PM |
Value | 8388608 | 4194304 | 2097152 | 1048576 | 524288 | 262144 | 131072 | 65536 | 32768 | 16384 | 8192 | 4096 | 2048 | 1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Bit |
Click the Bit row for non-working hours and the value for property is: , (hexa), (octal), (binary)
Every bit from the less significant bit, in the NonworkingHours property specifies whether the hour is a not-working or working hour. For instance, if you want to highlight that only 9AM is a not-working hour, you should set the 10th bit in the property on 1 ( the hours starts from 0 to 23 ), and so the value for the NonworkingHours property is 512 ( which binary representation is 1000000000 ). The hours in the property starts from 0AM for the first less significant bit, 1AM for the second bit, like in the following table.
For instance, if you need the representation of non-working hours from 6PM to 8AM, you need to set on 1 each representative bit in the NonworkingHours property, or to add corresponding values in the last row in the table for each non-working hours, so in this case the NonworkingHours property is 16253183 or in binary 111110000000000011111111. For instance, if the NonworkingHours property is 0 or NonworkingHoursPattern is exPatternEmpty the not-working hours are not highlighted. Use the NonworkingDays property to specify non-working days. Use the Add("A:B") to add a bar that displays the bar A in the working area, and B in non-working areas.
The following function gets the value for the Chart.NonworkingHours property, giving start and end day shift hours:Public Function getNonworkingHours(ByVal startTime As Date, ByVal endTime As Date) As Long Dim nNonworkingHours As Long, d As Double, n As Long, i As Long, dHour As Double, dSec As Double nNonworkingHours = 0 dHour = 1 / 24 dSec = dHour / 60 / 60 d = 0 n = 1 For i = 1 To 24 If (((d < startTime) And (Abs(d - startTime) > dSec)) Or ((d > endTime) And (Abs(d - endTime) > dSec))) Then nNonworkingHours = nNonworkingHours + n End If n = n * 2 d = d + dHour Next getNonworkingHours = nNonworkingHours End Function
The getNonworkingHours function, takes the start / end time ( values between 0 and 1 ), and returns the value to specify for the Chart.NonworkingHours property. For instance, the G2antt1.Chart.NonworkingHours = getNonworkingHours(#6:00:00 AM#, #6:00:00 PM#) specifies working hours between 06:00 AM and 06:00 PM (inclusive).