chartjs / chartjs-plugin-zoom

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

Unwanted behavior when dragging outside of chart area #895

Closed joshkel closed 1 day ago

joshkel commented 2 days ago

I've noticed a couple of issues with zoom drag rectangles in 2.1.0. (I believe this relates to #811; I was experimenting with that PR's changes locally earlier. I apologize for not following up sooner.)

First, I believe that the behavior is more intuitive / feels cleaner to the end user if the drag rectangle pegs to the edge of the chart area, instead of allowing the rectangle to go beyond the chart area then doing something different with the actual results. (I realize this may be subjective.)

Second, the behavior when the rectangle does go beyond the chart area feels weird. Using https://codepen.io/joshkel/pen/LYwKzwR as a demo, if I click a bit below and to the left of the last point then to the bottom right corner of the canvas (outside of the chart area):

https://github.com/user-attachments/assets/24e423b7-ec69-4759-b7ff-dc8c770cc383