Skip to content

#313 populate searchdata even if hoverinfo === 'none' #2

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ function hover(gd, evt, subplot) {
hovermode = 'array';
for(itemnum = 0; itemnum<evt.length; itemnum++) {
cd = gd.calcdata[evt[itemnum].curveNumber||0];
if(cd[0].trace.hoverinfo!=='none') searchData.push(cd);
searchData.push(cd);
}
}
else {
for(curvenum = 0; curvenum<gd.calcdata.length; curvenum++) {
cd = gd.calcdata[curvenum];
trace = cd[0].trace;
if(trace.hoverinfo!=='none' && subplots.indexOf(trace.xaxis + trace.yaxis)!==-1) {
if(subplots.indexOf(trace.xaxis + trace.yaxis)!==-1) {
searchData.push(cd);
}
}
Expand Down
64 changes: 64 additions & 0 deletions test/jasmine/tests/click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,70 @@ describe('click interactions', function() {
});
});

describe('click events with hoverinfo set to none', function() {
var futureData;

beforeEach(function(done) {
gd = createGraphDiv();

var mockCopy = Lib.extendDeep({}, mock);
mockCopy.data[0].hoverinfo = 'none';
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
.then(done);

gd.on('plotly_click', function(data) {
futureData = data;
});
});

it('should contain the correct fields despite hoverinfo: "none"', function() {
click(pointPos[0], pointPos[1]);
expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];
expect(Object.keys(pt)).toEqual([
'data', 'fullData', 'curveNumber', 'pointNumber',
'x', 'y', 'xaxis', 'yaxis'
]);
expect(pt.curveNumber).toEqual(0);
expect(pt.pointNumber).toEqual(11);
expect(pt.x).toEqual(0.125);
expect(pt.y).toEqual(2.125);
});
});

describe('click events with hoverinfo set to none', function() {
var futureData;

beforeEach(function(done) {
gd = createGraphDiv();

var mockCopy = Lib.extendDeep({}, mock);
mockCopy.data[0].hoverinfo = 'none';
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
.then(done);

gd.on('plotly_hover', function(data) {
futureData = data;
});
});

it('should contain the correct fields despite hoverinfo: "none"', function() {
click(pointPos[0], pointPos[1]);
expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];
expect(Object.keys(pt)).toEqual([
'data', 'fullData', 'curveNumber', 'pointNumber',
'x', 'y', 'xaxis', 'yaxis'
]);
expect(pt.curveNumber).toEqual(0);
expect(pt.pointNumber).toEqual(11);
expect(pt.x).toEqual(0.125);
expect(pt.y).toEqual(2.125);
});
});

describe('double click events', function() {
var futureData;

Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var customMatchers = require('../assets/custom_matchers');
*/

var PLOT_DELAY = 200;
var MOUSE_DELAY = 20;
var MOUSE_DELAY = 60;
var MODEBAR_DELAY = 500;


Expand Down
25 changes: 25 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,31 @@ describe('hover info', function() {
});
});

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

mockCopy.data[0].hoverinfo = 'none';

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

it('does not render if hover is set to none', function() {
var gd = document.getElementById('graph');
Fx.hover('graph', evt, 'xy');

var hoverTrace = gd._hoverdata[0];

expect(hoverTrace.curveNumber).toEqual(0);
expect(hoverTrace.pointNumber).toEqual(17);
expect(hoverTrace.x).toEqual(0.388);
expect(hoverTrace.y).toEqual(1);

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

describe('hoverformat', function() {

var data = [{
Expand Down