-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag to the outside of the chart doesn't work correctly #770
Comments
I see this same issue (with chart.js 3.9.1 and react 17.0.2) and can confirm that downgrading from 2.0.1 to 2.0.0 fixes it. I believe the cause is that getRelativePosition (called in computeDragRect, which is called in mouseUp) is returning a position relative to whatever element the mouse was over when the endPointEvent mouseup happened rather than the position relative to the chart canvas. chartjs-plugin-zoom/src/handlers.js Lines 80 to 120 in bfd207d
|
I was just about to create an issue for this. Unsure if there is active development on this plugin, but I think you should follow the The reason theirs doesn't work for you is because they seem to assume that any events passed to that method have an equivalent This gets you into situations where, when dragging out of the canvas, your start and end points get flipped. For example:
Another method to get canvas position would be to, instead of relying on You do need to clamp though, because while start and end won't flip accidentally, you could get an end position that is greater than the actual height or width of the canvas. In practice this just means that you will zoom slightly further past the current scale. |
Drag to the outside of the chart doesn't work correctly
It's only happen in
2.0.1
. I downgrade to2.0.0
, it works fine.In
2.0.1
, it seems that it calculated the length betweenmousedown
andmouseup
, so it shows longer range than expected.(I expect the range starts on the
mousedown
point, till the end of the chart)The text was updated successfully, but these errors were encountered: