Clicking on the gear in the chart display, zoom in using rubber band, then change to another option "points", "connected points", the chart was reset back before the zoom.
We should keep the chart zoom unchanged.
If the data to be plotted changes, yes, the zoom level should be reset.
But if the data does not change and only the style of plot changes, the zoom level should remain the same.
The axis ranges are calculated each time when an action is triggered through the option parameters passed in payload. When Zoom is selected, the zoom (it is a object literal: xMin, xMax, yMin and yMax)
is added to the options. However, the zoom information is lost when the line style change action is performed. The fix is
- Once the Zoom button is clicked, the zoom information is kept until reset zoom is performed
- When zoom is reset, the zoom is replaced by the data ranges which stored in the boundaries (xMin, xMax, yMin, yMax).
To my understanding the boundaries are safe to use because they are only be used when the axis ranges are calculated.
The alternate way to fix is to change props. But it may lead to make more changes.
The zoom is not a property in XYOptions. When the zoom is selected, it is added by calling updateSet in the reducer(CHART_OPTIONS_UPDATE). When the line style is change, the zoom information is lost by calling updateMerge in the reducer(CHART_DATA_UPDATE). To keep the zoom, either we add a zoom property in XYOption or not to remove the zoom when calling upateMerge.
The implementation is as following:
- Add a zoom property in XYPlotOptions
- Call resultSuccessful in XYPlotOption with xyParameter as an argument that contains zoom, columns etc
- At the resultSuccessful, check if x or y column changes, set zoom to undefined, otherwise, set zoom to the xyParameter's zoom value if it exists.