chartjs / chartjs-plugin-zoom

Zoom and pan plugin for Chart.js
MIT License
586 stars 326 forks source link

Zoom reset for scales built with suggestedMin and suggestedMax #801

Open apirvane opened 9 months ago

apirvane commented 9 months ago

Hello,

Trying to summarize as much as possible, we have the following use case:

  1. A chart with two 'y' scales - both scales are created using the 'suggestedMin' and 'suggestedMax' properties
  2. Starts to zoom in
  3. Hides the scale and datasets of one of the 'y' scales - this is done via the native legend plugin of chartjs
  4. Resets zoom (this.chart.resetZoom()) - zoom is reset
  5. Observing the onZoomComplete callback, the previously hidden scale now has a 'min'=0 and 'max'=1
    • The expectation would be that the scale would have the initial values

If the chart scales are build using the 'min' and 'max' properties instead of the 'suggestedMin' and 'suggestedMax' (point 1), then the expectation is correctly met.

Thank you.