danieljordan
01-12-2023Data Storage
Dynamically Change Month order on X-Axis
Hello,
The end-user has requested the following, but I am having trouble adjusting the x-axis appropriately.
I have a line graph showing activity over the "Trailing 12 Months" (TTM). It is currently January, so this chart is correct. However next month the TTM should be from Feb-Jan.
If possible, I would like to dynamically change the x-axis labeling to start 12 months ago and end last month.
So:
- In Feb (Labeling start with Feb, Mar, Apr,... and ends with Jan)
- In Mar (Labeling start with Mar, Apr, May,... and ends with Feb)
- In Apr (Labeling start with Apr, May, Jun,... and ends with Mar)
- and so on..
Any Ideas?
Appreciate your time and help.
With some help from the old forums:
Set the date format on your x-axis to MMM-YYYY (Feb 1970 is the example generally used). This will ensure proper ordering of the years as well as the months.
Then use the following widget script to hide the year number:widget.on('render', function(widget,args){ widget.queryResult.xAxis.labels.formatter = function () { strArr = this.value.split(' ') return strArr[0] } })
Best of luck!
Iris