This demo demonstrates how to dynamically change granularity of data of the Serial chart. It enables to switch between monthly data (source data) and yearly (aggregated).
When user selects a granularity via dropdown, a custom code kicks in which:
- Takes either source data (monthly) or uses custom function to aggregate yearly data; (taking the last data point in each month)
- Updates chart's
- Sets proper granularity in category axis
- Sets proper format for cursor's category axis balloon via
- Calls chart's method
validateData()so the chart takes in new data.
The chart also has
zoomOutOnDataUpdate set to
true so that zoom selection is preserved across data set switches.