-
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
Zoom triggered when hiding/showing series by clicking legend #256
Zoom triggered when hiding/showing series by clicking legend #256
Comments
What version are you using? I thought this was fixed in the latest version |
Thank you for your answer. |
Hi. I updated to 0.7.3 but the problem still happens. If I can send any more information or be useful in any way please let me know. All the best. |
I'm not at my computer at the moment to test, but before it would happen with a click and that's what I thought was fixed. However, if you moved your mouse a very small distance while clicking that would be interpreted as a drag and zoom the chart. I wonder if you might be slightly moving the mouse without noticing. We perhaps should add a minimum distance the mouse must be moved to be considered a drag if that's the case. |
Oh yes you're right ! It's indeed the slight mouse movement that is triggering a drag event. Although the minimum distance trick sounds nice, perhaps it is possible to listen to mouse drag events on the "series" part of the chart only, and not the legend ? |
Yeah. We should do both. I think this PR would fix it: chartjs/Chart.js#6227 |
I tried to apply this Chart.js 3.x fix to Chart.js 2.9.3 but it didn't seem to help in case of zoom plugin. |
If user starts mouse down for example in area of legends or axis the zoom starts. This fix limits the starting of zooming to the area of the actual graph. Fixes chartjs#256
@benmccann Was it bad idea to combine 2fd819f "Fix: Honor zoom.mode (xy/x/y) when applying zoom.threshold" to the same pull request with the fix for this issue #256? |
Any news about this ? Thanks a lot |
Meanwhile waiting the merge, you can use the pull request source https://github.com/ikkala/chartjs-plugin-zoom -- of course more official patch would be nice. |
I think this is resolved in chart.js v3 and zoom plugin 1.0.0-beta.1 since the click is now limited to the chart area. |
Hi, I am currently working with chart.js v3.3 and chartjs-plugin-zoom v1.0 and experiencing this problem. A slight move on the label registers as mouse drag. |
Mouse drag on the legend is zooming for me |
I'm still getting this bug. If I click legends to hide/show data, the chart may suddenly zoom at random place. My legends are on the left side of the chart.
|
There was a related bug fixed in 1.2.0 (#574), @jussirantala can you try updating? |
Updated chart.js and this plugin. Still getting the same behaviour.
My plugin settings: |
Now I disabled "drag" option and I don't get the bug anymore. But the drag function was why I installed this plugin. |
Any news about this? To me this seems to be a rather common problem when using drag mode. |
Was there something problematic in my PR #772 that tries to fix this issue? |
The following workaround works for me: zoom: {
zoom: {
... ,
// check if clicked inside chart area. If this returns false, zooming is aborted and onZoomRejected is invoked
// see https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html#zoom-events
onZoomStart: e => e.point.x > e.chart.chartArea.left && e.point.x < e.chart.chartArea.right && e.point.y > e.chart.chartArea.top && e.point.y < e.chart.chartArea.bottom
}
} |
+1 for @grigoart workaround |
Hi.
I have a chart with 2 or more series, drag zoom feature enabled, pan feature disabled, and chart legend enabled.
Sometimes when clicking multiple times the chart legend to show/hide one series or another, a zoom event is suddenly triggered (
onZoomComplete
callback is executed) and everything disappears: chart axis show ranges totally outside the data range.Calling
resetZoom()
make things go back to normal.I'm using the following configuration
Thanks in advance for any help.
Mathias
The text was updated successfully, but these errors were encountered: