From c8b05edc2ed13ac3ec58f0b1ef45bed47554f253 Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Sun, 17 Apr 2016 11:32:33 +0200 Subject: [PATCH 1/4] #313 enable hover point data collection even if hoverinfo is set to none --- src/plots/cartesian/graph_interact.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plots/cartesian/graph_interact.js b/src/plots/cartesian/graph_interact.js index 8ff557f7674..d9fe06469d8 100644 --- a/src/plots/cartesian/graph_interact.js +++ b/src/plots/cartesian/graph_interact.js @@ -367,14 +367,14 @@ function hover(gd, evt, subplot) { hovermode = 'array'; for(itemnum = 0; itemnum Date: Sun, 17 Apr 2016 11:33:22 +0200 Subject: [PATCH 2/4] #313 increase mouse related time delay to avoid stochastic test failing --- test/jasmine/tests/gl_plot_interact_test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index add05802397..bf3a472656e 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -52,7 +52,6 @@ describe('Test gl plot interactions', function() { destroyGraphDiv(); }); - // ... function delay(done) { setTimeout(done, 0); } From 92a7c908fd5fd03e27a9412c721394f6581acf35 Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Sun, 17 Apr 2016 11:33:50 +0200 Subject: [PATCH 3/4] #313 test cases --- test/jasmine/tests/click_test.js | 64 ++++++++++++++++++++++++++ test/jasmine/tests/hover_label_test.js | 25 ++++++++++ 2 files changed, 89 insertions(+) diff --git a/test/jasmine/tests/click_test.js b/test/jasmine/tests/click_test.js index fe1a1e39d18..7511bcd14b2 100644 --- a/test/jasmine/tests/click_test.js +++ b/test/jasmine/tests/click_test.js @@ -96,6 +96,70 @@ describe('Test 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; diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index 37e3c7b27b6..29cef75bfe8 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -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 = [{ From 1c6014a9530b73a536242691432b1848ab1f458b Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Sun, 17 Apr 2016 12:02:53 +0200 Subject: [PATCH 4/4] #313 rebase post-merge change --- test/jasmine/tests/click_test.js | 18 ++++++++---------- test/jasmine/tests/gl_plot_interact_test.js | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/jasmine/tests/click_test.js b/test/jasmine/tests/click_test.js index 7511bcd14b2..269dedd5f2b 100644 --- a/test/jasmine/tests/click_test.js +++ b/test/jasmine/tests/click_test.js @@ -96,15 +96,14 @@ describe('Test click interactions:', function() { }); }); - describe('click events with hoverinfo set to none', function() { + describe('click event with hoverinfo set to none - plotly_click', 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) + 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) { @@ -128,15 +127,14 @@ describe('Test click interactions:', function() { }); }); - describe('click events with hoverinfo set to none', function() { + describe('click events with hoverinfo set to none - plotly_hover', 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) + var modifiedMockCopy = Lib.extendDeep({}, mockCopy); + modifiedMockCopy.data[0].hoverinfo = 'none'; + Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout) .then(done); gd.on('plotly_hover', function(data) { diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index bf3a472656e..d0fa3ddd278 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -52,6 +52,7 @@ describe('Test gl plot interactions', function() { destroyGraphDiv(); }); + // put callback in the event queue function delay(done) { setTimeout(done, 0); }