Skip to content
Merged
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
8 changes: 6 additions & 2 deletions src/plots/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ module.exports = {
valType: 'flaglist',
role: 'info',
flags: ['x', 'y', 'z', 'text', 'name'],
extras: ['all', 'none'],
extras: ['all', 'none', 'skip'],
dflt: 'all',
description: 'Determines which trace information appear on hover.'
description: [
'Determines which trace information appear on hover.',
'If `none` or `skip` are set, no information is displayed upon hovering.',
'But, if `none` is set, click and hover events are still fired.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Great. Thanks!

].join(' ')
},
stream: {
token: {
Expand Down
6 changes: 4 additions & 2 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,16 @@ function hover(gd, evt, subplot) {
hovermode = 'array';
for(itemnum = 0; itemnum < evt.length; itemnum++) {
cd = gd.calcdata[evt[itemnum].curveNumber||0];
searchData.push(cd);
if(cd[0].trace.hoverinfo !== 'skip') {
searchData.push(cd);
}
}
}
else {
for(curvenum = 0; curvenum < gd.calcdata.length; curvenum++) {
cd = gd.calcdata[curvenum];
trace = cd[0].trace;
if(subplots.indexOf(getSubplot(trace)) !== -1) {
if(trace.hoverinfo !== 'skip' && subplots.indexOf(getSubplot(trace)) !== -1) {
searchData.push(cd);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/plots/gl2d/scene2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ proto.draw = function() {
(y / glplot.pixelRatio) - (size.t + (1 - domainY[1]) * size.h)
);

if(result && fullLayout.hovermode) {
if(result && result.object._trace.hoverinfo !== 'skip' && fullLayout.hovermode) {
var nextSelection = result.object._trace.handlePick(result);

if(nextSelection && (
Expand All @@ -488,6 +488,7 @@ proto.draw = function() {
this.lastPickResult.dataCoord[1] !== nextSelection.dataCoord[1])
) {
var selection = nextSelection;

this.lastPickResult = {
traceUid: nextSelection.trace ? nextSelection.trace.uid : null,
dataCoord: nextSelection.dataCoord.slice()
Expand Down
2 changes: 1 addition & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function render(scene) {
var selection = scene.glplot.selection;
for(var i = 0; i < keys.length; ++i) {
trace = scene.traces[keys[i]];
if(trace.handlePick(selection)) {
if(trace.data.hoverinfo !== 'skip' && trace.handlePick(selection)) {
lastPicked = trace;
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/choropleth/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ plotChoropleth.style = function(geo) {
function makeCleanHoverLabelsFunc(geo, trace) {
var hoverinfo = trace.hoverinfo;

if(hoverinfo === 'none') {
if(hoverinfo === 'none' || hoverinfo === 'skip') {
return function cleanHoverLabelsFunc(pt) {
delete pt.nameLabel;
delete pt.textLabel;
Expand Down
2 changes: 1 addition & 1 deletion src/traces/pie/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = function plot(gd, cdpie) {
// in case we dragged over the pie from another subplot,
// or if hover is turned off
if(gd._dragging || fullLayout2.hovermode === false ||
hoverinfo === 'none' || !hoverinfo) {
hoverinfo === 'none' || hoverinfo === 'skip' || !hoverinfo) {
return;
}

Expand Down
42 changes: 42 additions & 0 deletions test/jasmine/tests/click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,48 @@ describe('Test click interactions:', function() {
});
});

describe('click event with hoverinfo set to skip - plotly_click', function() {
var futureData = null;

beforeEach(function(done) {

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

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

it('should not register the click', function() {
click(pointPos[0], pointPos[1]);
expect(futureData).toEqual(null);
});
});

describe('click events with hoverinfo set to skip - plotly_hover', function() {
var futureData = null;

beforeEach(function(done) {

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

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

it('should not register the hover', function() {
click(pointPos[0], pointPos[1]);
expect(futureData).toEqual(null);
});
});

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

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

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

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

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

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

expect(gd._hoverdata, undefined);
});
});

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

Expand Down