8000 Fixup hover on period positioned points by archmoj · Pull Request #5618 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fixup hover on period positioned points #5618

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 14 commits into from
May 13, 2021
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
Prev Previous commit
Next Next commit
adjust min and max positions of bars in respect to period alignment
  • Loading branch information
archmoj committed Apr 29, 2021
commit c96bf994eb39eacebf42477222c5b3e09cb1a24f
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