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
fresh start hover points with the winning point
  • Loading branch information
archmoj committed May 26, 2021
commit 71a14e95b7c5c776e321655625e64806a32b98eb
7 changes: 4 additions & 3 deletions src/components/fx/hover.js
B351
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
hoverData[0].trace.type !== 'splom' // TODO: add support for splom
) {
var winningPoint = hoverData[0];
hoverData = [winningPoint];

var customXVal = customVal('x', winningPoint, fullLayout);
var customYVal = customVal('y', winningPoint, fullLayout);
Expand All @@ -684,9 +685,9 @@ function _hover(gd, evt, subplot, noHoverEvent) {
} else {
var oldId = seen[key] - 1;
var oldHd = finalPoints[oldId];
if(
Math.abs(winningPoint.distance - newHd.distance) <
Math.abs(winningPoint.distance - oldHd.distance)
if(oldId > 0 &&
Math.abs(newHd.distance) <
Math.abs(oldHd.distance)
) {
// replace with closest
finalPoints[oldId] = newHd;
Expand Down
6 changes: 3 additions & 3 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5487,10 +5487,10 @@ describe('hovermode: (x|y)unified', function() {
.then(function(gd) {
_hover(gd, {curveNumber: 0});

assertLabel({title: 'Apr 13, 2014, 15:21:11', items: [
assertLabel({title: 'Apr 13, 2014, 15:21:15', items: [
'Outdoor (wun... : (Apr 13, 2014, 15:26:12, 69.4)',
'1st Floor (N... : (Apr 13, 2014, 15:21:15, 74.8)',
'2nd Floor (R... : 73.625',
'1st Floor (N... : 74.8',
'2nd Floor (R... : (Apr 13, 2014, 15:21:11, 73.625)',
'Attic (Ardui... : (Apr 13, 2014, 15:26:34, 98.49)'
]});
})
Expand Down
0