Skip to content

Use entityNearest() rather than entityNearestByXThenY() for LinePlot.entitiesAt()#3558

Open
mcintyret wants to merge 1 commit into
developfrom
tm/line-nearest
Open

Use entityNearest() rather than entityNearestByXThenY() for LinePlot.entitiesAt()#3558
mcintyret wants to merge 1 commit into
developfrom
tm/line-nearest

Conversation

@mcintyret
Copy link
Copy Markdown

@mcintyret mcintyret commented Oct 16, 2020

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:
image

After clicking at that exact same cursor location:
image

After this PR, the selected point is the expected one.

@blueprint-bot
Copy link
Copy Markdown

Use entityNearest() rather than entityNearestByXThenWhy() for LinePlot.entitiesAt()

Demo: quicktests | fiddle

Copy link
Copy Markdown
Contributor

@themadcreator themadcreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave the "unused" method since it's public

Comment thread src/plots/linePlot.ts
}
}

/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't delete this because technically this would be a public API break and require a major version bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants