Skip to content

Commit 71a14e9

Browse files
committed
fresh start hover points with the winning point
1 parent c692eda commit 71a14e9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/components/fx/hover.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
658658
hoverData[0].trace.type !== 'splom' // TODO: add support for splom
659659
) {
660660
var winningPoint = hoverData[0];
661+
hoverData = [winningPoint];
661662

662663
var customXVal = customVal('x', winningPoint, fullLayout);
663664
var customYVal = customVal('y', winningPoint, fullLayout);
@@ -684,9 +685,9 @@ function _hover(gd, evt, subplot, noHoverEvent) {
684685
} else {
685686
var oldId = seen[key] - 1;
686687
var oldHd = finalPoints[oldId];
687-
if(
688-
Math.abs(winningPoint.distance - newHd.distance) <
689-
Math.abs(winningPoint.distance - oldHd.distance)
688+
if(oldId > 0 &&
689+
Math.abs(newHd.distance) <
690+
Math.abs(oldHd.distance)
690691
) {
691692
// replace with closest
692693
finalPoints[oldId] = newHd;

test/jasmine/tests/hover_label_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,10 +5487,10 @@ describe('hovermode: (x|y)unified', function() {
54875487
.then(function(gd) {
54885488
_hover(gd, {curveNumber: 0});
54895489

5490-
assertLabel({title: 'Apr 13, 2014, 15:21:11', items: [
5490+
assertLabel({title: 'Apr 13, 2014, 15:21:15', items: [
54915491
'Outdoor (wun... : (Apr 13, 2014, 15:26:12, 69.4)',
5492-
'1st Floor (N... : (Apr 13, 2014, 15:21:15, 74.8)',
5493-
'2nd Floor (R... : 73.625',
5492+
'1st Floor (N... : 74.8',
5493+
'2nd Floor (R... : (Apr 13, 2014, 15:21:11, 73.625)',
54945494
'Attic (Ardui... : (Apr 13, 2014, 15:26:34, 98.49)'
54955495
]});
54965496
})

0 commit comments

Comments
 (0)