ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Date series aggregation, week number and quarter
Posted by Eirik on Sep-21-2020 21:45
Hi
In reference to the “Uneven Data Points” example (VBNetASP) – let’s say the data points was aggregated by either week number, month, quarter or year. The dates provided for each data point could maybe then be the last date in the aggregation period. I would then also like to have the x-axis display a date format corresponding to the aggregation.
For month or year aggregation that could be achieved by adding date/time formatting, e.g.:

c.xAxis().setLabelFormat("{value|mm/yyyy}")
or
c.xAxis().setLabelFormat("{value|yyyy}")

Is there a similar or alternative option/approach for displaying the corresponding week number or quarter?

  Re: Date series aggregation, week number and quarter
Posted by Peter Kwan on Sep-22-2020 02:40
Eirik wrote:

Hi
In reference to the “Uneven Data Points” example (VBNetASP) – let’s say the data points was aggregated by either week number, month, quarter or year. The dates provided for each data point could maybe then be the last date in the aggregation period. I would then also like to have the x-axis display a date format corresponding to the aggregation.
For month or year aggregation that could be achieved by adding date/time formatting, e.g.:

c.xAxis().setLabelFormat("{value|mm/yyyy}")
or
c.xAxis().setLabelFormat("{value|yyyy}")

Is there a similar or alternative option/approach for displaying the corresponding week number or quarter?

  Re: Date series aggregation, week number and quarter
Posted by Peter Kwan on Sep-22-2020 04:22
Hi Eirik,

In the "Uneven Data Points" sample code, both the x-axis and y-axis is auto-scaled, that is, the axis range and labels are automatically determined. If your data cover the first 6 months of the year, ChartDirector might the labels at (2020-01-01, 2020-02-01, 2020-03-01, 2020-04-01. 2020-05-01, 2020-06-01). If you format the six labels it to display "quarters", they will come (Q1, Q1, Q1, Q2, Q2, Q2). Note there there can be duplicated labels.

I would guess if you choose quarterly labels, you would expect at most one label per quarter. In this case, you would need to use Axis.setDateScale to specify the axis scale as well as the label spacing. For example:

' one label every 3 months
c.xAxis().setDateScale(startDate, endDate, 90 * 86400)

You can format the labels to display quarters Q1, Q2, .... by using:

c.xAxis().setLabelFormat("Q{=({value|m}+ 1.25)/3|0}")

If you want to display the quarter with the year (like Q1 2020), you can use:

c.xAxis().setLabelFormat("Q{=({value|m}+ 1.25)/3|0} {value|yyyy}")


For weekly labels, because of the complications in how the week number is determined, you may need to specify the week numbers directly using Axis.setLinearScale2. For example:

c.xAxis().setDateScale2(startDate, endDate, anArrayOfTextString)

In the above, anArrayOfTextString is an array of text strings that contain the labels you want to put on the axis. The labels will be spread evenly between startDate and endDate. See:

https://www.advsofteng.com/doc/cdnet.htm#Axis.setLinearScale2.htm

Regards
Peter Kwan