chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.92k stars 11.89k forks source link

Setting Y-Min for bar chart messes with interactions/tooltips #11733

Open Travja opened 3 months ago

Travja commented 3 months ago

Expected behavior

When setting the interaction axis to 'x', intersect false, mode 'nearest' and then setting the y scale min value to 1, I would expect that hovering above the bars on the chart would show a tooltip on each of the bars.

Current behavior

Hovering over the individual bars does nothing. It's not until your cursor actually intersects the bars that the tooltip appears. If I change the y-min to 0.5, it appears to work normally. Setting it to 0.8 doesn't catch the shorter bars in the example, but does appear to work more like one would expect.

Reproducible sample

https://codepen.io/Travja/pen/eYoVjNg

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.4.2

Browser name and version

Chrome 123.0.6312.105

Link to your project

No response

LeeLenaleee commented 2 months ago

I gave it a quick look, seems like we take the middle point of an element and see if it is inside the chart area, which in this case is not.

Wil look more into this next week

Travja commented 1 month ago

Not a high priority at all, but @LeeLenaleee have you had a chance to look into this any more?