Skip to content

Bug fix waterfall hovermode closest decreasing values #3778

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

Merged
merged 3 commits into from
Apr 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixes Waterfall hovermode closest bug 3776
  • Loading branch information
archmoj committed Apr 16, 2019
commit 0836042d0c276a23643175a374692af38a89b114
12 changes: 10 additions & 2 deletions src/traces/bar/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
var trace = cd[0].trace;
var t = cd[0].t;
var isClosest = (hovermode === 'closest');
var isWaterfall = (trace.type === 'waterfall');
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I guess it would be annoying to move this logic in waterfall/hover.js. 😞

var maxHoverDistance = pointData.maxHoverDistance;
var maxSpikeDistance = pointData.maxSpikeDistance;

Expand Down Expand Up @@ -82,10 +83,17 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
}

function sizeFn(di) {
var v = sizeVal;
var b = di.b;
var s = di[sizeLetter];

if(isWaterfall) {
s += Math.abs(di.rawS || 0);
}

// add a gradient so hovering near the end of a
// bar makes it a little closer match
return Fx.inbox(di.b - sizeVal, di[sizeLetter] - sizeVal,
maxHoverDistance + (di[sizeLetter] - sizeVal) / (di[sizeLetter] - di.b) - 1);
return Fx.inbox(b - v, s - v, maxHoverDistance + (s - v) / (s - b) - 1);
}

if(trace.orientation === 'h') {
Expand Down