Skip to content

Commit

Permalink
adjust min and max positions of bars in respect to period alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Apr 29, 2021
1 parent 689adfa commit c96bf99
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/traces/bar/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,22 @@ function hoverOnBars(pointData, xval, yval, hovermode) {

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

function thisBarMinPos(di) { return di[posLetter] - di.w / 2; }
function thisBarMaxPos(di) { return di[posLetter] + di.w / 2; }
function thisBarMinPos(di) { return thisBarExtPos(di, -1); }
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }

function thisBarExtPos(di, sgn) {
var w = di.w;
var delta = sgn * w;
if(trace[posLetter + 'period']) {
var alignment = trace[posLetter + 'periodalignment'];
if(alignment === 'start') {
delta = (sgn === -1) ? 0 : w;
} else if(alignment === 'end') {
delta = (sgn === -1) ? -w : 0;
}
}
return di[posLetter] + delta / 2;
}

var minPos = isClosest ?
thisBarMinPos :
Expand Down

0 comments on commit c96bf99

Please sign in to comment.