ChartDirector 7.0 (ASP/COM/VB Edition)

ArrayMath.selectStartOfWeek


Usage

selectStartOfWeek([ majorTickStep [, initialMargin ]])

Description

Selects the elements of the ArrayMath object that represents a different week from the previous element.

This method assumes the elements of the ArrayMath object are dates/times.

The primary purpose of this method is to select the appropriate elements as ticks on an enumerated axis.

Suppose you want to plot a variable against time. The x-values of the data points will be an array of dates/times. If an enumerated x-axis is used (see Axis.setLabels), there will be a tick at every data point, which may be too dense if there are too many data points.

This method can be used to reduce the ticks to one tick per week (or one tick per multiple weeks). This is by selecting the dates/times in the data array only if it is not the same week as the previous element in the array. The selected elements will be left unchanged, while the elements not select will be replaced by NoValue. The resulting array can be used directly in Axis.setLabels2.

For the first data point, there is no previous data point to compare, so it is handled differently. The first data point will be selected if it is near the beginning of the week it represents. By default, near means within 2 days (172800 seconds). This is configurable using the initialMargin argument.

Note that if the data points does not have data in a certain time range, no element can be selected in that time range, and so there will be no tick for that time range. This is appropriate for many chart types, such as finance charts, in which missing time ranges (non-trading hours, holidays, etc) are traditionally skipped.

However, if the data points may contain missing time ranges, but the ticks cannot be skipped, it may be more appropriate to use a non-enumerated x-axis by using Layer.setXData and Axis.setDateScale3 (or Axis.setDateScale or Axis.setDateScale2).

Arguments

ArgumentDefaultDescription
majorTickStep1The tick step. A value of n means one tick per n weeks.
initialMargin172800The margin for the first data point. The first data point will be selected if it is within initialMargin number of seconds from beginning of the week it represents. The default is 2 days (172800 seconds).

Return Value

The current ArrayMath object.