Skip to content

Commit 1903583

Browse files
committed
remove problematic hover filter and adjust tests
1 parent 2b58ca2 commit 1903583

File tree

2 files changed

+0
-89
lines changed

2 files changed

+0
-89
lines changed

src/components/fx/hover.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ function _hover(gd, evt, subplot, noHoverEvent) {
708708
}
709709

710710
// Remove duplicated hoverData points
711-
// note that d3 also filters identical points in the rendering steps
712711
var repeated = {};
713712
hoverData = hoverData.filter(function(hd) {
714713
var key = hoverDataKey(hd);
@@ -820,9 +819,7 @@ function createHoverText(hoverData, opts, gd) {
820819
var xa = c0.xa;
821820
var ya = c0.ya;
822821
var axLetter = hovermode.charAt(0);
823-
var v0 = c0[axLetter + 'LabelVal'];
824822
var t0 = c0[axLetter + 'Label'];
825-
var t00 = (String(t0) || '').split(' ')[0];
826823
var outerContainerBB = outerContainer.node().getBoundingClientRect();
827824
var outerTop = outerContainerBB.top;
828825
var outerWidth = outerContainerBB.width;
@@ -1011,44 +1008,13 @@ function createHoverText(hoverData, opts, gd) {
10111008
}
10121009

10131010
label.attr('transform', strTranslate(lx, ly));
1014-
1015-
// remove the "close but not quite" points
1016-
// because of error bars, only take up to a space
1017-
hoverData = filterClosePoints(hoverData);
10181011
});
10191012

1020-
function filterClosePoints(hoverData) {
1021-
return hoverData.filter(function(d) {
1022-
if(d.zLabelVal !== undefined) return true;
1023-
if((d[axLetter + 'Label'] || '').split(' ')[0] === t00) return true;
1024-
if(d.trace[axLetter + 'period']) {
1025-
var v = d[axLetter + 'LabelVal'];
1026-
var ax = d[axLetter + 'a'];
1027-
var trace = {};
1028-
trace[axLetter + 'period'] = d.trace[axLetter + 'period'];
1029-
trace[axLetter + 'period0'] = d.trace[axLetter + 'period0'];
1030-
1031-
trace[axLetter + 'periodalignment'] = 'start';
1032-
var start = alignPeriod(trace, ax, axLetter, [v])[0];
1033-
1034-
trace[axLetter + 'periodalignment'] = 'end';
1035-
var end = alignPeriod(trace, ax, axLetter, [v])[0];
1036-
1037-
if(v0 >= start && v0 < end) return true;
1038-
}
1039-
1040-
return false;
1041-
});
1042-
}
1043-
10441013
// Show a single hover label
10451014
if(helpers.isUnifiedHover(hovermode)) {
10461015
// Delete leftover hover labels from other hovermodes
10471016
container.selectAll('g.hovertext').remove();
10481017

1049-
// similarly to compare mode, we remove the "close but not quite together" points
1050-
if((t0 !== undefined) && (c0.distance <= opts.hoverdistance)) hoverData = filterClosePoints(hoverData);
1051-
10521018
// Return early if nothing is hovered on
10531019
if(hoverData.length === 0) return;
10541020

test/jasmine/tests/hover_label_test.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,40 +1714,6 @@ describe('hover info', function() {
17141714
})
17151715
.then(done, done.fail);
17161716
});
1717-
1718-
it('should avoid overlaps on *too close* pts are filtered out', function(done) {
1719-
Plotly.newPlot(gd, [
1720-
{name: 'A', x: [9, 10], y: [9, 10]},
1721-
{name: 'B', x: [8, 9], y: [9, 10]},
1722-
{name: 'C', x: [9, 10], y: [10, 11]}
1723-
], {
1724-
hovermode: 'x',
1725-
xaxis: {range: [0, 100]},
1726-
yaxis: {range: [0, 100]},
1727-
width: 700,
1728-
height: 450
1729-
})
1730-
.then(function() { _hover(gd, 67, 239); })
1731-
.then(function() {
1732-
var nodesA = hoverInfoNodes('A');
1733-
var nodesC = hoverInfoNodes('C');
1734-
1735-
// Ensure layout correct
1736-
assertLabelsInsideBoxes(nodesA, 'A');
1737-
assertLabelsInsideBoxes(nodesC, 'C');
1738-
assertSecondaryRightToPrimaryBox(nodesA, 'A');
1739-
assertSecondaryRightToPrimaryBox(nodesC, 'C');
1740-
1741-
// Ensure stacking, finally
1742-
var boxA = nodesA.primaryBox.getBoundingClientRect();
1743-
var boxC = nodesC.primaryBox.getBoundingClientRect();
1744-
1745-
// Be robust against floating point arithmetic and subtle future layout changes
1746-
expect(calcLineOverlap(boxA.top, boxA.bottom, boxC.top, boxC.bottom))
1747-
.toBeWithin(0, 1);
1748-
})
1749-
.then(done, done.fail);
1750-
});
17511717
});
17521718

17531719
describe('constraints info graph viewport', function() {
@@ -4708,27 +4674,6 @@ describe('hovermode: (x|y)unified', function() {
47084674
.then(done, done.fail);
47094675
});
47104676

4711-
it('shares filtering logic with compare mode x', function(done) {
4712-
var mock = require('@mocks/27.json');
4713-
var mockCopy = Lib.extendDeep({}, mock);
4714-
4715-
Plotly.newPlot(gd, mockCopy)
4716-
.then(function(gd) {
4717-
_hover(gd, { xval: '2002' });
4718-
assertElementCount('g.hovertext', 2);
4719-
4720-
return Plotly.relayout(gd, 'hovermode', 'x unified');
4721-
})
4722-
.then(function() {
4723-
_hover(gd, { xval: '2002' });
4724-
assertLabel({title: '2002.042', items: [
4725-
'Market income : 0.5537845',
4726-
'Market incom... : 0.4420997'
4727-
]});
4728-
})
4729-
.then(done, done.fail);
4730-
});
4731-
47324677
it('case of scatter points on period bars', function(done) {
47334678
Plotly.newPlot(gd, {
47344679
data: [

0 commit comments

Comments
 (0)