8000 Pick closest points to the winning point in compare mode and position unified hover box in front of winning point by archmoj · Pull Request #5683 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Pick closest points to the winning point in compare mode and position unified hover box in front of winning point #5683

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 10 commits into from
May 28, 2021
Prev Previous commit
Next Next commit
init variables fixing hover error
  • Loading branch information
archmoj committed May 26, 2021
commit fa67044b436f55d276a3e296bbc5b73cd330e26c
40 changes: 21 additions & 19 deletions src/traces/bar/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,35 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {

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

if(trace.orientation === 'h') {
posVal = yval;
sizeVal = xval;
posLetter = 'y';
sizeLetter = 'x';
dx = sizeFn;
dy = positionFn;
} else {
posVal = xval;
sizeVal = yval;
posLetter = 'x';
sizeLetter = 'y';
dy = sizeFn;
dx = positionFn;
}

var period = trace[posLetter + 'period'];

function thisBarMinPos(di) { return thisBarExtPos(di, -1); }
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }

function thisBarExtPos(di, sgn) {
if(di.orig_p !== undefined) {
if(period) {
return di.p + sgn * Math.abs(di.p - di.orig_p);
}
return di[posLetter] + sgn * di.w / 2;
}

var minPos = isClosest || trace[posLetter + 'period'] ?
var minPos = isClosest || period ?
thisBarMinPos :
function(di) {
/*
Expand All @@ -63,7 +81,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2);
};

var maxPos = isClosest || trace[posLetter + 'period'] ?
var maxPos = isClosest || period ?
thisBarMaxPos :
function(di) {
return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2);
Expand Down Expand Up @@ -121,22 +139,6 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
return Fx.inbox(b - v, s - v, maxSpikeDistance + (s - v) / (s - b) - 1);
}

if(trace.orientation === 'h') {
posVal = yval;
sizeVal = xval;
posLetter = 'y';
sizeLetter = 'x';
dx = sizeFn;
dy = positionFn;
} else {
posVal = xval;
sizeVal = yval;
posLetter = 'x';
sizeLetter = 'y';
dy = sizeFn;
dx = positionFn;
}

var pa = pointData[posLetter + 'a'];
var sa = pointData[sizeLetter + 'a'];

Expand Down
0