chartjs / chartjs-plugin-zoom

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

zoom mode: "x" drag: true can't work threshold #496

Closed yoshimax closed 3 years ago

yoshimax commented 3 years ago

I just click graph select range 0 (+MAX) on zoom mode: "x" drag: true.

Looks mode: "x" computeDragRect return value no calc always rerurn some value.

It means can't work here. if (dragDistanceX <= zoomThreshold && dragDistanceY <= zoomThreshold) { return; }

Report bug.


zoom: { enabled: true, drag: true, mode: "x", threshold: 2, onZoomComplete: this.onZoomComplete, onZoomStart: this.onZoomStart, onZoom: this.onZoom },

Logs

mouseUp zoom.js

chartjs-plugin-zoom.js?f634:462 xEnabled: true chartjs-plugin-zoom.js?f634:463 yEnabled: false chartjs-plugin-zoom.js?f634:506 rect.left: 341 chartjs-plugin-zoom.js?f634:507 rect.right: 341 chartjs-plugin-zoom.js?f634:508 rect.top: 32 chartjs-plugin-zoom.js?f634:509 rect.bottom: 286.07365326524837 chartjs-plugin-zoom.js?f634:510 zoomThreshold: 2

chartjs-plugin-zoom.js?f634:511 dragDistanceX: 0 chartjs-plugin-zoom.js?f634:512 dragDistanceY: 254.07365326524837

kurkle commented 3 years ago

Some clarification, did you select 0 pixels wide area, or did you select whole chart and it calculated the area to be 0 pixels wide?

kurkle commented 3 years ago

If I understand correctly, you just clicked and it selected a 0 wide area. Did it also zoom to that?

yoshimax commented 3 years ago

Yes, Just click (not drug) also Zoom.

Just one click dragDistanceY always return large value .

Will can't work here. if (dragDistanceX <= zoomThreshold && dragDistanceY <= zoomThreshold) { return; }