Skip to content

Show box/violin position when hovering over pts - #3441

Merged
etpinard merged 1 commit into
masterfrom
boxpoint-hover-fix-numeric-positions
Jan 21, 2019
Merged

etpinard merged 1 commit into
masterfrom
boxpoint-hover-fix-numeric-positions

Conversation

@etpinard

@etpinard etpinard commented Jan 17, 2019 •

Copy link
Copy Markdown
Contributor

... 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
Copy Markdown
Contributor Author

cc @plotly/plotly_js

@antoinerg

Copy link
Copy Markdown
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