chartjs / chartjs-plugin-zoom

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

After zooming in too much, straight line shifts upwards #797

Closed ale-coe closed 2 weeks ago

ale-coe commented 1 year ago

Current behavior

In an unzoomed state the blue dot is located directly on the line (the line itself is an annotation and the blue dot is part of a scatter chart). img_1 If I zoom in too much, the line shifts upwards and the dot is not located on the line anymore. img_2

Swapping the annotation with a line chart or a scatter chart does not fix the issue.

Expected behavior

The zoomlevel does not affect how the line is displayed.

Reproducible sample

See this codepen.

fehmisener commented 7 months ago

Hey,

I'm having the same problem, did you find a solution?

kurkle commented 2 weeks ago

This is (at least) related to the fact that getPixelForValue limites its result to -32767..32767. When the annotation (or line) closest point is far enough in some direction, it gets limited. If I remember correctly, canvas has similar limitations.

maybe limit the zooming? and/or use a line chart instead of annotation with many points.