8000 Fix hovermode 'closest' + hoverinfo 'none' with superimposed data bug by etpinard · Pull Request #495 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fix hovermode 'closest' + hoverinfo 'none' with superimposed data bug #495

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 2 commits into from
May 2, 2016
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
add 'closest' hover mode test cases
  • Loading branch information
etpinard committed May 2, 2016
commit 416fa8b6b7f3c1246acc38ef91c8f251d52d99cd
64 changes: 64 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,70 @@ describe('hover info', function() {
});
});

describe('\'closest\' hover info (superimposed case)', function() {
var mockCopy = Lib.extendDeep({}, mock);

// superimposed traces
mockCopy.data.push(Lib.extendDeep({}, mockCopy.data[0]));
mockCopy.layout.hovermode = 'closest';

var gd;

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

it('render hover labels of the above trace', function() {
Fx.hover('graph', evt, 'xy');

expect(gd._hoverdata.length).toEqual(1);

var hoverTrace = gd._hoverdata[0];

expect(hoverTrace.fullData.index).toEqual(1);
expect(hoverTrace.curveNumber).toEqual(1);
expect(hoverTrace.pointNumber).toEqual(16);
expect(hoverTrace.x).toEqual(0.33);
expect(hoverTrace.y).toEqual(1.25);

expect(d3.selectAll('g.axistext').size()).toEqual(0);
expect(d3.selectAll('g.hovertext').size()).toEqual(1);

var expectations = ['PV learning ...', '(0.33, 1.25)'];
d3.selectAll('g.hovertext').selectAll('text').each(function(_, i) {
expect(d3.select(this).html()).toEqual(expectations[i]);
});
});

it('render only non-hoverinfo \'none\' hover labels', function(done) {

Plotly.restyle(gd, 'hoverinfo', ['none', 'name']).then(function() {
Fx.hover('graph', evt, 'xy');

expect(gd._hoverdata.length).toEqual(1);

var hoverTrace = gd._hoverdata[0];

expect(hoverTrace.fullData.index).toEqual(1);
expect(hoverTrace.curveNumber).toEqual(1);
expect(hoverTrace.pointNumber).toEqual(16);
expect(hoverTrace.x).toEqual(0.33);
expect(hoverTrace.y).toEqual(1.25);

expect(d3.selectAll('g.axistext').size()).toEqual(0);
expect(d3.selectAll('g.hovertext').size()).toEqual(1);

var text = d3.selectAll('g.hovertext').select('text');
expect(text.size()).toEqual(1);
expect(text.html()).toEqual('PV learning ...');

done();
});

});
});

describe('hoverformat', function() {

var data = [{
Expand Down
0