Skip to content

Commit c96bf99

Browse files
committed
adjust min and max positions of bars in respect to period alignment
1 parent 689adfa commit c96bf99

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/traces/bar/hover.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,22 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
3535

3636
var posVal, sizeVal, posLetter, sizeLetter, dx, dy, pRangeCalc;
3737

38-
function thisBarMinPos(di) { return di[posLetter] - di.w / 2; }
39-
function thisBarMaxPos(di) { return di[posLetter] + di.w / 2; }
38+
function thisBarMinPos(di) { return thisBarExtPos(di, -1); }
39+
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }
40+
41+
function thisBarExtPos(di, sgn) {
42+
var w = di.w;
43+
var delta = sgn * w;
44+
if(trace[posLetter + 'period']) {
45+
var alignment = trace[posLetter + 'periodalignment'];
46+
if(alignment === 'start') {
47+
delta = (sgn === -1) ? 0 : w;
48+
} else if(alignment === 'end') {
49+
delta = (sgn === -1) ? -w : 0;
50+
}
51+
}
52+
return di[posLetter] + delta / 2;
53+
}
4054

4155
var minPos = isClosest ?
4256
thisBarMinPos :

0 commit comments

Comments
 (0)