From discussion #88: The ChartWidget shall be extended to allow users the local selection of different (pre-configured) time intervals. For simpler implementation, this shall not influence the fetching of the data series data, but instead only reconfigure the Chart.js x axis accordingly.
For pre-configuring the available time intervals, the ChartWidget constructor shall be extended with a new (optional) parameter selectable_intervals, taking a list of datetime.timedelta and corresponding label strings. If this parameter is set, the interval parameter must match one of the selectable_intervals entries. It is then used as the default interval, which is shown initially when opening the web page.
If this parameter is set, the list of intervals and corresponding labels is passed to the JavaScript code via the data-spec JSON attribute. The JavaScript shall then create a button group below the chart itself, according to this list. Instead of fetching the time series data for the configured (default) interval, the JavaScript code shall fetch the time series data for the maximum interval defined in the selectable_intervals list. The JavaScript code shall track the current selected interval and update the color of the buttons and the configuration of the Chart.js x-axis accordingly.
From discussion #88: The
ChartWidgetshall be extended to allow users the local selection of different (pre-configured) time intervals. For simpler implementation, this shall not influence the fetching of the data series data, but instead only reconfigure the Chart.js x axis accordingly.For pre-configuring the available time intervals, the
ChartWidgetconstructor shall be extended with a new (optional) parameterselectable_intervals, taking a list ofdatetime.timedeltaand corresponding label strings. If this parameter is set, theintervalparameter must match one of theselectable_intervalsentries. It is then used as the default interval, which is shown initially when opening the web page.If this parameter is set, the list of intervals and corresponding labels is passed to the JavaScript code via the
data-specJSON attribute. The JavaScript shall then create a button group below the chart itself, according to this list. Instead of fetching the time series data for the configured (default) interval, the JavaScript code shall fetch the time series data for the maximum interval defined in the selectable_intervals list. The JavaScript code shall track the current selected interval and update the color of the buttons and the configuration of the Chart.js x-axis accordingly.