property Items.ItemNonworkingUnits(Item as HITEM, [InsideZoom as Variant]) as String
Gets or sets a value that indicates the formula to specify the use non-working units for the item.

 TypeDescription 
   Item as HITEM A long expression that specifies handle of the item being changed.  
   InsideZoom as Variant A Boolean expression that specifies whether the format is applied to normal view or when the item displays inside zoom units. By default, it is False, so the format is applied to all units, including the inside zoom units. If True, the specified format is applied only to visible inside units in the item. If False, the pattern and the color for non-working days is applied, else if True, the pattern and the color for non-working hours is applied.  
   String A String expression that specifies the formula to determine the non-working area for the item. The value keyword in the expression specifies the unit being verified.  
by default, the ItemNonworkingUnits property is empty. The ItemNonworkingUnits property has effect only if it is not empty, syntactically correct and the ShowNonworkingDates property is True. Use the ItemNonworkingUnits property to specify different non-working zones for different items. The NonworkingDays property specifies the days in the week as being non-working. The NonworkingHours property specifies the hours in the day as being non-working. If the ItemNonworkingUnits property is not empty and syntactically correct, the NonworkingDays property or NonworkingHours property has no effect, so the ItemNonworkingUnits property specify a new non-working zone for the item. The value keyword in the ItemNonworkingUnits property specifies the the unit being verified. For instance, weekday(value) = 0 means Sunday, or month(value) = 1 means January, and so on. Bellow the pictures, you can find the known/supported operators, operations and functions by the user defined non-working feature. The IsNonworkingDate property indicates whether the giving date-time is a working or non-working unit. The ItemBar(exBarTreatAsNonworking) property indicates whether a bar is treated as a non-working part of the item.

The control supports the following ways of specify the non-working parts for items:

In case, you need to specify the minutes or hours for your chart go here.

The following screen shot shows the chart when no custom non-working area is displayed:

The following screen shot shows the chart when custom non-working area is displayed ( the bolded items have different non-working areas, as default ):

The following screen shot shows the chart when custom non-working area is displayed, for inside zoom units too ( Jan 3 is an inside zoom unit ):

 

The supported binary arithmetic operators are:

The supported unary boolean operators are:

The supported binary boolean operators are:

The supported binary boolean operators, all these with the same priority 0, are :

The supported ternary operators, all these with the same priority 0, are :

"expression ? true_part : false_part"

, while it executes and returns the true_part if the expression is true, else it executes and returns the false_part. For instance, the "%0 = 1 ? 'One' : (%0 = 2 ? 'Two' : 'not found')" returns 'One' if the value is 1, 'Two' if the value is 2, and 'not found' for any other value. A n-ary equivalent operation is the case() statement, which is available in newer versions of the component.

The supported n-ary operators are (with priority 5):

"expression in (c1,c2,c3,...cn)"

, where the c1, c2, ... are constant elements. The constant elements could be numeric, date or string expressions. For instance the "value in (11,22,33,44,13)" is equivalent with "(expression = 11) or (expression = 22) or (expression = 33) or (expression = 44) or (expression = 13)". The in operator is not a time consuming as the equivalent or version is, so when you have large number of constant elements it is recommended using the in operator. Shortly, if the collection of elements has 1000 elements the in operator could take up to 8 operations in order to find if an element fits the set, else if the or statement is used, it could take up to 1000 operations to check, so by far, the in operator could save time on finding elements within a collection.

"expression switch (default,c1,c2,c3,...,cn)"

, where the c1, c2, ... are constant elements, and the default is a constant element being returned when the element is not found in the collection. The constant elements could be numeric, date or string expressions.  The equivalent syntax is "%0 = c 1 ? c 1 : ( %0 = c 2 ? c 2 : ( ... ? . : default) )". The switch operator is very similar with the in operator excepts that the first element in the switch is always returned by the statement if the element is not found,  while the returned value is the value itself instead -1. For instance, the "%0 switch ('not found',1,4,7,9,11)" gets 1, 4, 7, 9 or 11, or 'not found' for any other value. As the in operator the switch operator uses binary searches for fitting the element, so it is quicker that iif (immediate if operator) alterative.

"expression case ([default : default_expression ; ] c1 : expression1 ; c2 : expression2 ; c3 : expression3 ;....)"

If the default part is missing, the case() operator returns the value of the expression if it is not found in the collection of cases ( c1, c2, ...). For instance, if the value of expression is not any of c1, c2, .... the default_expression is executed and returned. If the value of the expression is c1, then the case() operator executes and returns the expression1. The default, c1, c2, c3, ... must be constant elements as numbers, dates or strings. For instance, the "date(shortdate(value)) case (default:0 ; #1/1/2002#:1 ; #2/1/2002#:1; #4/1/2002#:1; #5/1/2002#:1)" indicates that only #1/1/2002#, #2/1/2002#,  #4/1/2002# and  #5/1/2002# dates returns 1, since the others returns 0. For instance the following sample specifies the hour being non-working for specified dates: "date(shortdate(value)) case(default:0;#4/1/2009# : hour(value) >= 6 and hour(value) <= 12 ; #4/5/2009# : hour(value) >= 7 and hour(value) <= 10 or hour(value) in(15,16,18,22); #5/1/2009# : hour(value) <= 8)" statement indicates the working hours for dates as follows:

The in, switch and case() use binary search to look for elements so they are faster then using iif and or expressions.

Obviously, the priority of the operations inside the expression is determined by ( ) parenthesis and the priority for each operator. 

The supported conversion unary operators are:

Other known operators for numbers are:

Other known operators for strings are:

Other known operators for dates are:

The expression supports also immediate if ( similar with iif in visual basic, or ? : in C++ ) ie cond ? value_true : value_false, which means that once that cond is true the value_true is used, else the value_false is used. Also, it supports variables, up to 10 from 0 to 9. For instance, 0:="Abc" means that in the variable 0 is "Abc", and =:0 means retrieves the value of the variable 0. You can use variables to avoid computing several times the same thing.

The following VB sample shows how can I add a different non-working area for different items:

With G2antt1
	.Columns.Add "Non-Work"
	With .Chart
		.FirstWeekDay = exMonday
		.FirstVisibleDate = #1/24/2008#
		.PaneWidth(False) = 52
		.LevelCount = 2
	End With
	With .Items
		h = .AddItem("January")
		.ItemNonworkingUnits(h,False) = "month(value) = 1"
		h = .AddItem("February, Saturday, Sunday")
		.ItemNonworkingUnits(h,False) = "month(value) = 2 or (weekday(value) = 0 or weekday(value) = 6)"
		h = .AddItem("Sunday")
		.ItemNonworkingUnits(h,False) = "weekday(value) = 0"
	End With
End With
The following VB.NET sample shows how can I add a different non-working area for different items:
Dim h
With AxG2antt1
	.Columns.Add "Non-Work"
	With .Chart
		.FirstWeekDay = EXG2ANTTLib.WeekDayEnum.exMonday
		.FirstVisibleDate = #1/24/2008#
		.PaneWidth(False) = 52
		.LevelCount = 2
	End With
	With .Items
		h = .AddItem("January")
		.ItemNonworkingUnits(h,False) = "month(value) = 1"
		h = .AddItem("February, Saturday, Sunday")
		.ItemNonworkingUnits(h,False) = "month(value) = 2 or (weekday(value) = 0 or weekday(value) = 6)"
		h = .AddItem("Sunday")
		.ItemNonworkingUnits(h,False) = "weekday(value) = 0"
	End With
End With
The following C++ sample shows how can I add a different non-working area for different items:
/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXG2ANTTLib' for the library: 'ExG2antt 1.0 Control Library'

	#import <ExG2antt.dll>
	using namespace EXG2ANTTLib;
*/
EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
spG2antt1->GetColumns()->Add(L"Non-Work");
EXG2ANTTLib::IChartPtr var_Chart = spG2antt1->GetChart();
	var_Chart->PutFirstWeekDay(EXG2ANTTLib::exMonday);
	var_Chart->PutFirstVisibleDate("1/24/2008");
	var_Chart->PutPaneWidth(VARIANT_FALSE,52);
	var_Chart->PutLevelCount(2);
EXG2ANTTLib::IItemsPtr var_Items = spG2antt1->GetItems();
	long h = var_Items->AddItem("January");
	var_Items->PutItemNonworkingUnits(h,VARIANT_FALSE,L"month(value) = 1");
	h = var_Items->AddItem("February, Saturday, Sunday");
	var_Items->PutItemNonworkingUnits(h,VARIANT_FALSE,L"month(value) = 2 or (weekday(value) = 0 or weekday(value) = 6)");
	h = var_Items->AddItem("Sunday");
	var_Items->PutItemNonworkingUnits(h,VARIANT_FALSE,L"weekday(value) = 0");
The following C# sample shows how can I add a different non-working area for different items:
axG2antt1.Columns.Add("Non-Work");
EXG2ANTTLib.Chart var_Chart = axG2antt1.Chart;
	var_Chart.FirstWeekDay = EXG2ANTTLib.WeekDayEnum.exMonday;
	var_Chart.FirstVisibleDate = "1/24/2008";
	var_Chart.set_PaneWidth(false,52);
	var_Chart.LevelCount = 2;
EXG2ANTTLib.Items var_Items = axG2antt1.Items;
	int h = var_Items.AddItem("January");
	var_Items.set_ItemNonworkingUnits(h,false,"month(value) = 1");
	h = var_Items.AddItem("February, Saturday, Sunday");
	var_Items.set_ItemNonworkingUnits(h,false,"month(value) = 2 or (weekday(value) = 0 or weekday(value) = 6)");
	h = var_Items.AddItem("Sunday");
	var_Items.set_ItemNonworkingUnits(h,false,"weekday(value) = 0");
The following VFP sample shows how can I add a different non-working area for different items:
with thisform.G2antt1
	.Columns.Add("Non-Work")
	with .Chart
		.FirstWeekDay = 1
		.FirstVisibleDate = {^2008-1-24}
		.PaneWidth(.F.) = 52
		.LevelCount = 2
	endwith
	with .Items
		h = .AddItem("January")
		.DefaultItem = h
		.ItemNonworkingUnits(0,.F.) = "month(value) = 1"
		h = .AddItem("February, Saturday, Sunday")
		.DefaultItem = h
		.ItemNonworkingUnits(0,.F.) = "month(value) = 2 or (weekday(value) = 0 or weekday(value) = 6)"
		h = .AddItem("Sunday")
		.DefaultItem = h
		.ItemNonworkingUnits(0,.F.) = "weekday(value) = 0"
	endwith
endwith

Here's few things you should specify, in case you need to highlight the non-working part of the chart using minutes or hours.

The following screen shot shows few items with different non-working units.

For instance, the first item in the chart specifies the non-working units as 12:30 to 14:00 from Monday to Thursday, 12:30 to 13:30 on Friday, Sunday and Saturday non-working. 

The equivalent function that can be used  in this case is:

Items.ItemNonworkingUnits(h) = "weekday(value) case (default:((timeF(value)>="12:30:00" and timeF(value) <="14:00:00" ));5:( timeF(value)>="12:30:00" and timeF(value) <="13:30:00" );6:1;0:1) "

The definition for the chart's levels should be as:

With G2antt1
	With .Chart
		.LevelCount = 3
		.UnitScale = exHour
		With .Level(2)
			.Unit = exMinute
			.Count = 60
		End With
		.ResizeUnitScale = exMinute
		.ResizeUnitCount = 15
	End With
End With

It is important that the base level ( 2 ) should have the Unit scale on exMinute, so the ItemNonworkingUnit function will go up to minute.


Send comments on this topic.
© 1999-2012 Exontrol.COM, Software. All rights reserved.