ArrayMath& selectStartOfMonth(int majorTickStep = 1, double initialMargin = 432000);
Selects the elements of the ArrayMath object that represents a different month 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 month (or one tick per multiple months). This is by selecting the dates/times in the data array only if it is not the same month 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 month it represents. By default, near means within 5 days (432000 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).
© 2023 Advanced Software Engineering Limited. All rights reserved.