Skip to content

Fix hover label exponent hiding or gl3d log hover #1949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2017
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
11 changes: 11 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
20 changes: 20 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down