Skip to content

Fix for #6614 #6615

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 6 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions draftlogs/6615_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix to prevent accessing undefined (hoverText.hoverLabels) in case all currently shown markers have hoverinfo: "none" [#6614]([https://github.com/plotly/plotly.js/pull/5854](https://github.com/plotly/plotly.js/issues/6614)),
with thanks to @Domino987 for the contribution!
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ function createHoverText(hoverData, opts) {
container.selectAll('g.hovertext').remove();
var groupedHoverData = hoverData.filter(function(data) {return data.hoverinfo !== 'none';});
// Return early if nothing is hovered on
if(groupedHoverData.length === 0) return;
if(groupedHoverData.length === 0) return [];

// mock legend
var hoverlabel = fullLayout.hoverlabel;
Expand Down
34 changes: 34 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4726,6 +4726,40 @@ describe('hovermode: (x|y)unified', function() {
.then(done, done.fail);
});

it('should not fail if only hoverinfo: "none" are current visible', function(done) {
Plotly.newPlot(gd, {
data: [{
name: 'A',
x: [1, 100],
y: [1, 1]
}, {
name: 'B',
y: [1],
x: [50],
hoverinfo: 'none'
}],
layout: {
xaxis: {range: [40, 60]},
hovermode: 'x unified',
showlegend: false,
width: 500,
height: 500,
margin: {
t: 50,
b: 50,
l: 50,
r: 50
}
}
})
.then(function() {
_hover(gd, { xpx: 200, ypx: 200 });
expect(gd._hoverdata, undefined);
assertHoverLabelContent({});
})
.then(done, done.fail);
});

it('y unified should work for x/y cartesian traces', function(done) {
var mockCopy = Lib.extendDeep({}, mock);
mockCopy.layout.hovermode = 'y unified';
Expand Down