Use entityNearest() rather than entityNearestByXThenY() for LinePlot.entitiesAt() #3558
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Usinig
entityNearestByXThenY
causes some weird behaviour - if the cursor is marginally closer in the x domain to another point than the one the user intended to click on, that point will be the one that gets selected - even if it is hundreds of pixels away in the y domain.Even worse, the tooltip-on-hover codepath just uses
entityNearest()
, so the intuitive nearest point has a tooltip, but then clicking selects a different point.I went through the git history and couldn't see any reason why the "by x then y" approach was taken, but may well be missing something.
Hovering showing the nearest point:
After clicking at that exact same cursor location:
After this PR, the selected point is the expected one.