Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show box/violin position when hovering over pts #3441

Merged
merged 1 commit into from
Jan 21, 2019

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Jan 17, 2019

... instead of showing the point's position - fixes #3440

https://codepen.io/etpinard/pen/NeVaYR?editors=1010

now looks like:

peek 2019-01-17 10-27

Note that this was only a problem for box/violin traces with numeric positions (e.g. with set x and y arrays) under hovermode:'closest', as deeper down Fx.hover

if(d.xLabelVal !== undefined) {
d.xLabel = ('xLabel' in d) ? d.xLabel : Axes.hoverLabelText(d.xa, d.xLabelVal);
d.xVal = d.xa.c2d(d.xLabelVal);
}
if(d.yLabelVal !== undefined) {
d.yLabel = ('yLabel' in d) ? d.yLabel : Axes.hoverLabelText(d.ya, d.yLabelVal);
d.yVal = d.ya.c2d(d.yLabelVal);
}

calls Axes.hoverLabelText which then formats the positions back to categories with:

function formatCategory(ax, out) {
var tt = ax._categories[Math.round(out.x)];
if(tt === undefined) tt = '';
out.text = String(tt);
}

... instead of showing the point's position.
@etpinard etpinard added bug something broken status: reviewable labels Jan 17, 2019
@etpinard
Copy link
Contributor Author

cc @plotly/plotly_js

@antoinerg
Copy link
Contributor

Thanks for the fix @etpinard! Test is clear and simple 👌

Codepen with the fix: https://codepen.io/anon/pen/BMaNzV

💃

@etpinard etpinard merged commit 7652b90 into master Jan 21, 2019
@etpinard etpinard deleted the boxpoint-hover-fix-numeric-positions branch January 21, 2019 23:45
@etpinard etpinard mentioned this pull request Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Box plot: hover position of points is off
2 participants