diff --git a/src/plots/attributes.js b/src/plots/attributes.js index 52b03c671ed..c2b79cb419d 100644 --- a/src/plots/attributes.js +++ b/src/plots/attributes.js @@ -72,7 +72,7 @@ module.exports = { valType: 'flaglist', role: 'info', flags: ['x', 'y', 'z', 'text', 'name'], - extras: ['all', 'none'], + extras: ['all', 'none', 'hide'], dflt: 'all', description: 'Determines which trace information appear on hover.' }, diff --git a/src/plots/cartesian/graph_interact.js b/src/plots/cartesian/graph_interact.js index a367d6e65b3..fb4e3c925e6 100644 --- a/src/plots/cartesian/graph_interact.js +++ b/src/plots/cartesian/graph_interact.js @@ -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 !== 'none') { + 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 !== 'none' && subplots.indexOf(getSubplot(trace)) !== -1) { searchData.push(cd); } } diff --git a/src/traces/choropleth/plot.js b/src/traces/choropleth/plot.js index b440f60cdf2..76b88763055 100644 --- a/src/traces/choropleth/plot.js +++ b/src/traces/choropleth/plot.js @@ -165,7 +165,7 @@ plotChoropleth.style = function(geo) { function makeCleanHoverLabelsFunc(geo, trace) { var hoverinfo = trace.hoverinfo; - if(hoverinfo === 'none') { + if(hoverinfo === 'none' || hoverinfo === 'hide') { return function cleanHoverLabelsFunc(pt) { delete pt.nameLabel; delete pt.textLabel; diff --git a/src/traces/pie/plot.js b/src/traces/pie/plot.js index e96c21fbf77..9faaf2ffc91 100644 --- a/src/traces/pie/plot.js +++ b/src/traces/pie/plot.js @@ -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 === 'hide' || !hoverinfo) { return; } diff --git a/src/traces/scattergeo/plot.js b/src/traces/scattergeo/plot.js index 921dce93b84..75c19393483 100644 --- a/src/traces/scattergeo/plot.js +++ b/src/traces/scattergeo/plot.js @@ -244,7 +244,7 @@ plotScatterGeo.style = function(geo) { function makeCleanHoverLabelsFunc(geo, trace) { var hoverinfo = trace.hoverinfo; - if(hoverinfo === 'none') { + if(hoverinfo === 'none' || hoverinfo === 'hide') { return function cleanHoverLabelsFunc(d) { delete d.textLabel; }; } diff --git a/test/jasmine/tests/click_test.js b/test/jasmine/tests/click_test.js index 8dd517cdd15..5e948cf9693 100644 --- a/test/jasmine/tests/click_test.js +++ b/test/jasmine/tests/click_test.js @@ -83,7 +83,28 @@ describe('Test click interactions:', function() { }); describe('click event with hoverinfo set to none - plotly_click', function() { - var futureData; + var futureData = null; + + beforeEach(function(done) { + + var modifiedMockCopy = Lib.extendDeep({}, mockCopy); + modifiedMockCopy.data[0].hoverinfo = 'none'; + Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout) + .then(done); + + gd.on('plotly_click', function(data) { + futureData = data; + }); + }); + + it('should not register the hover', function() { + click(pointPos[0], pointPos[1]); + expect(futureData).toEqual(null); + }); + }); + + describe('click events with hoverinfo set to none - plotly_hover', function() { + var futureData = null; beforeEach(function(done) { @@ -92,12 +113,33 @@ describe('Test click interactions:', function() { Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout) .then(done); + gd.on('plotly_hover', function(data) { + futureData = data; + }); + }); + + it('should not register the click', function() { + click(pointPos[0], pointPos[1]); + expect(futureData).toEqual(null); + }); + }); + + describe('click event with hoverinfo set to hide - plotly_click', function() { + var futureData; + + beforeEach(function(done) { + + var modifiedMockCopy = Lib.extendDeep({}, mockCopy); + modifiedMockCopy.data[0].hoverinfo = 'hide'; + Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout) + .then(done); + gd.on('plotly_click', function(data) { futureData = data; }); }); - it('should contain the correct fields despite hoverinfo: "none"', function() { + it('should contain the correct fields despite hoverinfo: "hide"', function() { click(pointPos[0], pointPos[1]); expect(futureData.points.length).toEqual(1); @@ -113,13 +155,13 @@ describe('Test click interactions:', function() { }); }); - describe('click events with hoverinfo set to none - plotly_hover', function() { + describe('click events with hoverinfo set to hide - plotly_hover', function() { var futureData; beforeEach(function(done) { var modifiedMockCopy = Lib.extendDeep({}, mockCopy); - modifiedMockCopy.data[0].hoverinfo = 'none'; + modifiedMockCopy.data[0].hoverinfo = 'hide'; Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout) .then(done); @@ -128,7 +170,7 @@ describe('Test click interactions:', function() { }); }); - it('should contain the correct fields despite hoverinfo: "none"', function() { + it('should contain the correct fields despite hoverinfo: "hide"', function() { click(pointPos[0], pointPos[1]); expect(futureData.points.length).toEqual(1); diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index 8f4c71e0eae..2454e716551 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -309,7 +309,24 @@ describe('hover info', function() { Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done); }); - it('does not render if hover is set to none', function() { + it('does not hover if hover info is set to none', function() { + var gd = document.getElementById('graph'); + Fx.hover('graph', evt, 'xy'); + + expect(gd._hoverdata, undefined); + }); + }); + + describe('hover info hide', function() { + var mockCopy = Lib.extendDeep({}, mock); + + mockCopy.data[0].hoverinfo = 'hide'; + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done); + }); + + it('does not render if hover is set to hide', function() { var gd = document.getElementById('graph'); Fx.hover('graph', evt, 'xy');