Skip to content

Commit a55cadd

Browse files
authored
Merge pull request #1949 from plotly/fix-gl3d-hover
Fix hover label exponent hiding or gl3d log hover
2 parents cb2d3d1 + 709b058 commit a55cadd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/plots/cartesian/axes.js

+11
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,17 @@ function formatDate(ax, out, hover, extraPrecision) {
12981298
function formatLog(ax, out, hover, extraPrecision, hideexp) {
12991299
var dtick = ax.dtick,
13001300
x = out.x;
1301+
1302+
if(hideexp === 'never') {
1303+
// If this is a hover label, then we must *never* hide the exponent
1304+
// for the sake of display, which could give the wrong value by
1305+
// potentially many orders of magnitude. If hideexp was 'never', then
1306+
// it's now succeeded by preventing the other condition from automating
1307+
// this choice. Thus we can unset it so that the axis formatting takes
1308+
// precedence.
1309+
hideexp = '';
1310+
}
1311+
13011312
if(extraPrecision && ((typeof dtick !== 'string') || dtick.charAt(0) !== 'L')) dtick = 'L3';
13021313

13031314
if(ax.tickformat || (typeof dtick === 'string' && dtick.charAt(0) === 'L')) {

test/jasmine/tests/hover_label_test.js

+20
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,26 @@ describe('hover info', function() {
199199
});
200200
});
201201

202+
describe('hover info y on log axis', function() {
203+
var mockCopy = Lib.extendDeep({}, mock);
204+
205+
mockCopy.data[0].hoverinfo = 'y';
206+
207+
beforeEach(function(done) {
208+
for(var i = 0; i < mockCopy.data[0].y.length; i++) {
209+
mockCopy.data[0].y[i] *= 1e9;
210+
}
211+
212+
Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done);
213+
});
214+
215+
it('responds to hover y+text', function() {
216+
Fx.hover('graph', evt, 'xy');
217+
218+
expect(d3.selectAll('g.hovertext').selectAll('text.nums').node().innerHTML).toEqual('1e+9');
219+
});
220+
});
221+
202222
describe('hover info y+text', function() {
203223
var mockCopy = Lib.extendDeep({}, mock);
204224

0 commit comments

Comments
 (0)