Skip to content

Commit 0836042

Browse files
committed
fixes Waterfall hovermode closest bug 3776
1 parent d996136 commit 0836042

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/traces/bar/hover.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
3434
var trace = cd[0].trace;
3535
var t = cd[0].t;
3636
var isClosest = (hovermode === 'closest');
37+
var isWaterfall = (trace.type === 'waterfall');
3738
var maxHoverDistance = pointData.maxHoverDistance;
3839
var maxSpikeDistance = pointData.maxSpikeDistance;
3940

@@ -82,10 +83,17 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
8283
}
8384

8485
function sizeFn(di) {
86+
var v = sizeVal;
87+
var b = di.b;
88+
var s = di[sizeLetter];
89+
90+
if(isWaterfall) {
91+
s += Math.abs(di.rawS || 0);
92+
}
93+
8594
// add a gradient so hovering near the end of a
8695
// bar makes it a little closer match
87-
return Fx.inbox(di.b - sizeVal, di[sizeLetter] - sizeVal,
88-
maxHoverDistance + (di[sizeLetter] - sizeVal) / (di[sizeLetter] - di.b) - 1);
96+
return Fx.inbox(b - v, s - v, maxHoverDistance + (s - v) / (s - b) - 1);
8997
}
9098

9199
if(trace.orientation === 'h') {

0 commit comments

Comments
 (0)