chartjs / chartjs-plugin-zoom

Zoom and pan plugin for Chart.js
MIT License
579 stars 322 forks source link

Unequal amounts of zooming when using mouse wheel #767

Open hemmoleg opened 1 year ago

hemmoleg commented 1 year ago

Zooming in using the mouse wheel zooms in more then zooming out with the mouse wheel.

If you just add

wheel: {
  enabled: true
}

and then zoom in on step, the zoomLevel is 1.11, when you then zoom out on step, the zoomLevel is 1.01. This means that you always have to zoom out once more then what you zoomed in if you want to go back to zoomLevel 1. Also setting the speed property on the wheel object doesnt fix this.

You can try this for yourself by putting this

const config = {
  type: 'scatter',
  data: data,
  options: {
    scales: scales,
    plugins:{
      zoom:{
        zoom:{
          wheel:{
            enabled: true
          }
        }
      }
    }
  }
};

in the config of the demo chart here https://www.chartjs.org/chartjs-plugin-zoom/latest/samples/api.html. Then zoom in once using the mouse wheel, zoom out once using the mouse wheel. After that if you now click on the 'Reset zoom' button you will notice that the chart zooms out just a tiny bit more.