-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add error margin for detecting if a point or line is in the chartArea #5790
Conversation
Maybe 1% margin is too high because it allows 10px off the chart when a border is at 1000px from top/left. 0.01% should be fine. |
Do you think that using a percentage is the best solution or should we express |
Since we don’t need high precision, a margin in pixels seems to be easy to understand. |
I would like to address #5190 separately because it is about a layout issue while this is about a rounding error which can be easily fixed. |
Replaced |
Agreed that we should address #5190 separately. It would be useful to get your review on it since you're currently working on this part of the code and know it better than I do. It'd be great to get that one merged too if you think it's a good solution |
Do we need to fix the codeclimate issue? |
No, I don't think so |
Nice work @nagix. Does |
It’s from your #5597 ;) No one can tell if this distance from the border is inside or outside, and rounding errors usually happen around 10-15 or 10-16 |
Well done @nagix and thanks for the fix! |
@nagix I think this PR breaks some cases: if you test this example (code), you will notice that the last points disappear with master (maybe |
@simonbrunel This is related to #5797 and happens only when a category scale is used. As explained in #5797, |
Many issues about points/gridline at the top edge of the chart area being cut have been reported. The issue is caused by a decimal round-off error when detecting if a point or line is in the chartArea. This PR adds an err margin, which is already implemented for point clipping at the right and bottom edges.
v2.7.3: https://jsfiddle.net/nagix/z1bx459c/ (To reproduce the problem, you may need to resize the container as this is caused by decimal rounding)

v2.7.3 + This PR: https://jsfiddle.net/nagix/yv6emrcf/

Fixes #4579
Fixes #4790
Fixes #5493