plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

fix(axes): format tick labels correctly for small numbers in exponential notation

Open Hasnaathussain opened this issue 7 months ago • 2 comments

What this PR does

This PR fixes a bug in src/plots/cartesian/axes.js where formatting very small numbers could result in invalid tick strings (e.g. "-9.381779999999999e-") when String(v) produces exponential notation but the numFormat logic slices the string indiscriminately.

Fix details

When exponential notation is present, the logic now separates the mantissa from the exponent, applies precision formatting to the mantissa, and re-attaches the exponent string, avoiding string truncation that removes the exponential component.

Tested against locally failing reproductions and verified using test-jasmine to ensure no existing suites are broken.

Hasnaathussain avatar Apr 22 '26 19:04 Hasnaathussain

@camdecoster Applied! Replaced the custom mantissa slicing with a clean oFixed call.

Hasnaathussain avatar Jun 21 '26 11:06 Hasnaathussain

There was some funkiness with adding the rounding increment, so I made a few changes. Now the tests are passing! Speaking of which, could you please add some tests that check this new approach? Also, could you please add a draftlog?

camdecoster avatar Jun 24 '26 16:06 camdecoster

Hi @camdecoster, I've added the tests for this approach in numformat_test.js and added the draftlog as requested! All CI checks are passing successfully. Let me know if there's anything else needed.

Hasnaathussain avatar Jul 01 '26 18:07 Hasnaathussain

Friendly nudge @camdecoster! As everything is fully updated and all CI checks are passing, could you please take another look and approve this so we can merge? Thank you!

Hasnaathussain avatar Jul 07 '26 12:07 Hasnaathussain

I'm taking a look today.

camdecoster avatar Jul 13 '26 21:07 camdecoster