8000 Make hover spikes work when no tick labels are present by etpinard · Pull Request #1980 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Make hover spikes work when no tick labels are present #1980

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
Sep 5, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test for spike on showticklabels: false axes
  • Loading branch information
etpinard committed Sep 5, 2017
commit d306612e07d01cc9e1d315e9236caf5c6e9584e5
20 changes: 19 additions & 1 deletion test/jasmine/tests/hover_spikeline_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var Plotly = require('@lib/index');
var Fx = require('@src/components/fx');
var Lib = require('@src/lib');

var fail = require('../assets/fail_test');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');

Expand All @@ -16,6 +17,7 @@ describe('spikeline', function() {

describe('hover', function() {
var mockCopy = Lib.extendDeep({}, mock);
var gd;

mockCopy.layout.xaxis.showspikes = true;
mockCopy.layout.xaxis.spikemode = 'toaxis';
Expand All @@ -24,8 +26,10 @@ describe('spikeline', function() {
mockCopy.layout.xaxis2.showspikes = true;
mockCopy.layout.xaxis2.spikemode = 'toaxis';
mockCopy.layout.hovermode = 'closest';

beforeEach(function(done) {
Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done);
gd = createGraphDiv();
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
});

it('draws lines and markers on enabled axes', function() {
Expand All @@ -34,6 +38,20 @@ describe('spikeline', function() {
expect(d3.selectAll('circle.spikeline').size()).toEqual(1);
});

it('draws lines and markers on enabled axes w/o tick labels', function(done) {
Plotly.relayout(gd, {
'xaxis.showticklabels': false,
'yaxis.showticklabels': false
})
.then(function() {
Fx.hover('graph', {xval: 2, yval: 3}, 'xy');
expect(d3.selectAll('line.spikeline').size()).toEqual(4);
expect(d3.selectAll('circle.spikeline').size()).toEqual(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth verifying that these things have reasonable dimensions/positions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. done in 92b606b

})
.catch(fail)
.then(done);
});

it('doesn\'t draw lines and markers on disabled axes', function() {
Fx.hover('graph', {xval: 30, yval: 40}, 'x2y2');
expect(d3.selectAll('line.spikeline').size()).toEqual(2);
Expand Down
0