Skip to content

Commit 3ba7ec7

Browse files
committed
fixing hover for period group bars issue 5841
1 parent 3bdbedb commit 3ba7ec7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Diff for: src/traces/bar/hover.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
5858
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }
5959

6060
function thisBarExtPos(di, sgn) {
61-
var w = (period) ? di.wPeriod : di.w;
61+
var w = di.w;
6262

6363
return di[posLetter] + sgn * w / 2;
6464
}
6565

66-
var minPos = isClosestOrPeriod ?
67-
thisBarMinPos :
66+
var minPos = isClosest ?
67+
thisBarMinPos : period ?
68+
function(di) {
69+
var diff = di.pEnd - di.pStart;
70+
return di.p + diff / 2 - di.wPeriod;
71+
} :
6872
function(di) {
6973
/*
7074
* In compare mode, accept a bar if you're on it *or* its group.
@@ -81,8 +85,12 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
8185
return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2);
8286
};
8387

84-
var maxPos = isClosestOrPeriod ?
85-
thisBarMaxPos :
88+
var maxPos = isClosest ?
89+
thisBarMaxPos : period ?
90+
function(di) {
91+
var diff = di.pEnd - di.pStart;
92+
return di.p + diff / 2;
93+
} :
8694
function(di) {
8795
return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2);
8896
};

0 commit comments

Comments
 (0)