chartjs / chartjs-plugin-zoom

Zoom and pan plugin for Chart.js
MIT License
596 stars 327 forks source link

Changing zoom mode (drag) resets the zoom level #814

Open francescopenna opened 7 months ago

francescopenna commented 7 months ago

I am using a chart with this zoom configuration (pan is disabled):

zoom: {
  zoom: {
    mode: "xy",
    drag: {
      enabled: true,
      treshold: 100,
      drawTime: "afterDatasetsDraw",
    },
  }
}

I noticed that after a first zoom if I try to change the mode, for example with chart.config.options.plugins.zoom.zoom.mode = "y", the mode is succesfully changed, but the zoom level gets resetted. I made a sandbox showcasing this issue. In the example, try to change the zoom mode, zoom out, then change the zoom mode again to see the issue. Is this intended? And if so, is there a workaround for this? Thanks in advance

kurkle commented 1 week ago

I'd tend to think this has something to do with vue-chartjs. Try zooming out multiple times (say 5) and then change the mode. Maybe it also clones the animations in the options or something like that.