From 26f90992010c2b2e61a63c087a6d1524e58e15b7 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Fri, 11 Aug 2017 15:21:02 -0700 Subject: [PATCH 1/2] Fix hover label exponent hiding or gl3d log hover --- src/plots/cartesian/axes.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 5a2767c0d55..25d5f02f597 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -1298,6 +1298,17 @@ function formatDate(ax, out, hover, extraPrecision) { function formatLog(ax, out, hover, extraPrecision, hideexp) { var dtick = ax.dtick, x = out.x; + + if(hideexp === 'never') { + // If this is a hover label, then we must *never* hide the exponent + // for the sake of display, which could give the wrong value by + // potentially many orders of magnitude. If hideexp was 'never', then + // it's now succeeded by preventing the other condition from automating + // this choice. Thus we can unset it so that the axis formatting takes + // precedence. + hideexp = ''; + } + if(extraPrecision && ((typeof dtick !== 'string') || dtick.charAt(0) !== 'L')) dtick = 'L3'; if(ax.tickformat || (typeof dtick === 'string' && dtick.charAt(0) === 'L')) { From 709b0581c9173b87b73bfc223b92befb39fde14e Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Fri, 11 Aug 2017 15:57:11 -0700 Subject: [PATCH 2/2] Add test for log hover --- test/jasmine/tests/hover_label_test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index 92f713a722f..b28f044a0ed 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -199,6 +199,26 @@ describe('hover info', function() { }); }); + describe('hover info y on log axis', function() { + var mockCopy = Lib.extendDeep({}, mock); + + mockCopy.data[0].hoverinfo = 'y'; + + beforeEach(function(done) { + for(var i = 0; i < mockCopy.data[0].y.length; i++) { + mockCopy.data[0].y[i] *= 1e9; + } + + Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done); + }); + + it('responds to hover y+text', function() { + Fx.hover('graph', evt, 'xy'); + + expect(d3.selectAll('g.hovertext').selectAll('text.nums').node().innerHTML).toEqual('1e+9'); + }); + }); + describe('hover info y+text', function() { var mockCopy = Lib.extendDeep({}, mock);