Skip to content

Don't try to draw spikeline if the axis isn't on the chart. #1604

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ function createSpikelines(hoverData, opts) {
var c0 = hoverData[0];
var xa = c0.xa;
var ya = c0.ya;
var showX = xa.showspikes;
var showY = ya.showspikes;
var showX = xa.showspikes && xa.visible && (xa.showline || xa.showticklabels);
var showY = ya.showspikes && ya.visible && (ya.showline || ya.showticklabels);

// Remove old spikeline items
container.selectAll('.spikeline').remove();
Expand Down
14 changes: 14 additions & 0 deletions test/jasmine/tests/hover_spikeline_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,19 @@ describe('spikeline', function() {
expect(d3.selectAll('line.spikeline').size()).toEqual(2);
expect(d3.selectAll('circle.spikeline').size()).toEqual(0);
});

it('doesn\t draw a line when the axis isn\'t visible', function() {
Plotly.relayout('graph', 'yaxis.visible', false);
Fx.hover('graph', {xval: 2, yval: 3}, 'xy');
expect(d3.selectAll('line.spikeline').size()).toEqual(2);
expect(d3.selectAll('circle.spikeline').size()).toEqual(0);
});

it('doesn\t draw a line when the axis has no line or labels', function() {
Plotly.relayout('graph', ['yaxis.showticklabels', 'yaxis.showline'], [false, false]);
Fx.hover('graph', {xval: 2, yval: 3}, 'xy');
expect(d3.selectAll('line.spikeline').size()).toEqual(2);
expect(d3.selectAll('circle.spikeline').size()).toEqual(0);
});
});
});