Skip to content

Commit 97a8aef

Browse files
committed
fix 5292 - only filter close points of the same trace when unified
1 parent 3f33829 commit 97a8aef

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/fx/hover.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,27 @@ function createHoverText(hoverData, opts, gd) {
980980
});
981981
}
982982

983+
function unifiedFilterClosePoints(hoverData) {
984+
var out = [];
985+
var seen = [];
986+
for(var i = 0; i < hoverData.length; i++) {
987+
var d = hoverData[i];
988+
var id = d.cd[0].trace.index;
989+
if(!seen[id]) {
990+
seen[id] = 1;
991+
out.push(d);
992+
}
993+
}
994+
return out;
995+
}
996+
983997
// Show a single hover label
984998
if(helpers.isUnifiedHover(hovermode)) {
985999
// Delete leftover hover labels from other hovermodes
9861000
container.selectAll('g.hovertext').remove();
9871001

9881002
// similarly to compare mode, we remove the "close but not quite together" points
989-
if((t0 !== undefined) && (c0.distance <= opts.hoverdistance)) hoverData = filterClosePoints(hoverData);
1003+
if((t0 !== undefined) && (c0.distance <= opts.hoverdistance)) hoverData = unifiedFilterClosePoints(hoverData);
9901004

9911005
// Return early if nothing is hovered on
9921006
if(hoverData.length === 0) return;

0 commit comments

Comments
 (0)