Skip to content

Commit acb23c7

Browse files
author
John Soklaski
committed
Add hoverinfo skip
1 parent 7387b2b commit acb23c7

File tree

6 files changed

+66
-5
lines changed

6 files changed

+66
-5
lines changed

src/plots/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
valType: 'flaglist',
7373
role: 'info',
7474
flags: ['x', 'y', 'z', 'text', 'name'],
75-
extras: ['all', 'none'],
75+
extras: ['all', 'none', 'skip'],
7676
dflt: 'all',
7777
description: 'Determines which trace information appear on hover.'
7878
},

src/plots/cartesian/graph_interact.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,16 @@ function hover(gd, evt, subplot) {
394394
hovermode = 'array';
395395
for(itemnum = 0; itemnum < evt.length; itemnum++) {
396396
cd = gd.calcdata[evt[itemnum].curveNumber||0];
397-
searchData.push(cd);
397+
if(cd[0].trace.hoverinfo !== 'skip') {
398+
searchData.push(cd);
399+
}
398400
}
399401
}
400402
else {
401403
for(curvenum = 0; curvenum < gd.calcdata.length; curvenum++) {
402404
cd = gd.calcdata[curvenum];
403405
trace = cd[0].trace;
404-
if(subplots.indexOf(getSubplot(trace)) !== -1) {
406+
if(trace.hoverinfo !== 'skip' && subplots.indexOf(getSubplot(trace)) !== -1) {
405407
searchData.push(cd);
406408
}
407409
}

src/traces/choropleth/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ plotChoropleth.style = function(geo) {
165165
function makeCleanHoverLabelsFunc(geo, trace) {
166166
var hoverinfo = trace.hoverinfo;
167167

168-
if(hoverinfo === 'none') {
168+
if(hoverinfo === 'none' || hoverinfo === 'skip') {
169169
return function cleanHoverLabelsFunc(pt) {
170170
delete pt.nameLabel;
171171
delete pt.textLabel;

src/traces/pie/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = function plot(gd, cdpie) {
9696
// in case we dragged over the pie from another subplot,
9797
// or if hover is turned off
9898
if(gd._dragging || fullLayout2.hovermode === false ||
99-
hoverinfo === 'none' || !hoverinfo) {
99+
hoverinfo === 'none' || hoverinfo === 'skip' || !hoverinfo) {
100100
return;
101101
}
102102

test/jasmine/tests/click_test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,48 @@ describe('Test click interactions:', function() {
8282
});
8383
});
8484

85+
describe('click event with hoverinfo set to skip - plotly_click', function() {
86+
var futureData = null;
87+
88+
beforeEach(function(done) {
89+
90+
var modifiedMockCopy = Lib.extendDeep({}, mockCopy);
91+
modifiedMockCopy.data[0].hoverinfo = 'skip';
92+
Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)
93+
.then(done);
94+
95+
gd.on('plotly_click', function(data) {
96+
futureData = data;
97+
});
98+
});
99+
100+
it('should not register the click', function() {
101+
click(pointPos[0], pointPos[1]);
102+
expect(futureData).toEqual(null);
103+
});
104+
});
105+
106+
describe('click events with hoverinfo set to skip - plotly_hover', function() {
107+
var futureData = null;
108+
109+
beforeEach(function(done) {
110+
111+
var modifiedMockCopy = Lib.extendDeep({}, mockCopy);
112+
modifiedMockCopy.data[0].hoverinfo = 'skip';
113+
Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)
114+
.then(done);
115+
116+
gd.on('plotly_hover', function(data) {
117+
futureData = data;
118+
});
119+
});
120+
121+
it('should not register the hover', function() {
122+
click(pointPos[0], pointPos[1]);
123+
expect(futureData).toEqual(null);
124+
});
125+
});
126+
85127
describe('click event with hoverinfo set to none - plotly_click', function() {
86128
var futureData;
87129

test/jasmine/tests/hover_label_test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,23 @@ describe('hover info', function() {
300300
});
301301
});
302302

303+
describe('hover info skip', function() {
304+
var mockCopy = Lib.extendDeep({}, mock);
305+
306+
mockCopy.data[0].hoverinfo = 'skip';
307+
308+
beforeEach(function(done) {
309+
Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done);
310+
});
311+
312+
it('does not hover if hover info is set to skip', function() {
313+
var gd = document.getElementById('graph');
314+
Fx.hover('graph', evt, 'xy');
315+
316+
expect(gd._hoverdata, undefined);
317+
});
318+
});
319+
303320
describe('hover info none', function() {
304321
var mockCopy = Lib.extendDeep({}, mock);
305322

0 commit comments

Comments
 (0)