Type | Description | |||
Date as Variant | A Date expression that indicates the date being marked as nonworking day or a string expression that specifies the repetitive expression that defines the non-working days as Easter, Christmas or Holydays. For instance the "month(value)=7 or ( month(value) = 12 and day(value)=25 )" indicates July and December 25th is a non-working dates. The string version of the AddNonworkingDate supports value formatting. The value keyword indicates the date being queried. If the expression is not syntactically correct the non-working date expression is not added and so represented. |
The control supports the following ways of specify the non-working parts for items:
The following screen shot shows the chart with no custom non-working dates ( just defined by the NonworkingDays property as exSaturday and exSunday )
The following screen shot shows the chart with 3 custom non-working dates ( #12/22/2009#, #12/23/2009#, #12/24/2009# )
The following screen shot shows the chart with a repetitive formula defining the January the 1st and 6th as "month(value) = 1 and ( day(value) in (1,6) )"
2009
2008
The following screen shot shows the chart with a repetitive formula defining the year 2009 as being non-working and the April of 2010 using "year(value) = 2009 or (month(value) = 4 and year(value) = 2010)"
Here's few samples for repetitive expression:
"month(value) = 7" indicates the entire July month
"shortdateF(value) left 5 in ('01/01','01/06','04/25','05/01','06/02','08/15','11/01','12/08','12/25','12/26')" indicates Jan 1, Jan 6, Apr 25, May 1, Jun 2, Aug 15, Nov 1, Dec 8, Dec 25 (Christmas), Dec 26.
"month(value) = 1 and (day(value) in (1,6))" indicates the Jan 1 and Jan 6.
"hour(value) in (12,13,14)" indicates the time between 12 and 14 as being non-working.
"not(month(value) in (3,4)) ? 0 : ( floor(value)=floor(date(dateS('3/1/' + year(value)) + ((1:=(((255 - 11 * (year(value) mod 19)) - 21) mod 30) + 21) + (=:1 > 48 ? -1 : 0) + 6 - ((year(value) + int(year(value) / 4)) + =:1 + (=:1 > 48 ? -1 : 0) + 1) mod 7))))" indicates the Easter day.
"not(month(value) in (3,4,5)) ? 0 : ( floor(value)=(2:=floor(date(dateS('3/1/' + year(value)) + ((1:=(((255 - 11 * (year(value) mod 19)) - 21) mod 30) + 21) + (=:1 > 48 ? -1 : 0) + 6 - ((year(value) + int(year(value) / 4)) + =:1 + (=:1 > 48 ? -1 : 0) + 1) mod 7)))) or (floor(value)= =:2 + 1))" indicates the Easter Sunday and a day after
The expression supports predefined functions listed here. The value keyword in the expression indicates the date value being queried.
The following samples handles the DateChange event to add a new hard-coded date. The DateChange event notifies the application once the chart displays or changes its first visible date. This version could be time consuming, but it can be improved. For instance, you can add a member or a has table that changes / adds a new working date when the year is changed so actually the action could be added, only when the chart displays a new year.
The following VB sample marks the 11th of each month as nonworking day ( the code enumerates the visible dates, and marks one by one, if case ):
Private Sub G2antt1_DateChange() With G2antt1 .BeginUpdate With .Chart Dim d As Date d = .FirstVisibleDate Do While .IsDateVisible(d) If Day(d) = 11 Then If Not (.IsNonworkingDate(d)) Then .AddNonworkingDate d End If End If d = .NextDate(d, exDay, 1) Loop End With .EndUpdate End With End Sub
The following VB.NET sample marks the 11th of each month as nonworking day:
Private Sub AxG2antt1_DateChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxG2antt1.DateChange With AxG2antt1 .BeginUpdate() With .Chart Dim d As Date = .FirstVisibleDate Do While .IsDateVisible(d) If d.Day = 11 Then If Not (.IsNonworkingDate(d)) Then .AddNonworkingDate(d) End If End If d = .NextDate(d, EXG2ANTTLib.UnitEnum.exDay, 1) Loop End With .EndUpdate() End With End Sub
The following C# sample marks the 11th of each month as nonworking day:
private void axG2antt1_DateChange(object sender, EventArgs e) { axG2antt1.BeginUpdate(); EXG2ANTTLib.Chart chart = axG2antt1.Chart; DateTime d = Convert.ToDateTime(chart.FirstVisibleDate); while ( chart.get_IsDateVisible(d) ) { if ( d.Day == 11 ) if ( !chart.get_IsNonworkingDate( d ) ) chart.AddNonworkingDate(d); d = chart.get_NextDate(d, EXG2ANTTLib.UnitEnum.exDay, 1); } axG2antt1.EndUpdate(); } }
The following VFP sample marks the 11th of each month as nonworking day ( DateChange event ):
*** ActiveX Control Event *** With thisform.G2antt1 .BeginUpdate With .Chart local d d = .FirstVisibleDate Do While .IsDateVisible(d) If Day(d) = 11 Then If Not (.IsNonworkingDate(d)) Then .AddNonworkingDate(d) EndIf EndIf d = .NextDate(d, 4096, 1) enddo EndWith .EndUpdate EndWith