|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 ).
Click the Bit row for non-working hours and the value for property is:
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).