Skip to content
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

Fix rounding big numbers in pie & sunburst traces #5152

Merged
merged 2 commits into from
Sep 16, 2020
Merged

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Sep 16, 2020

Fixes #5122

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Sep 16, 2020
if(vRounded.lastIndexOf('.') !== -1) {
if(vRounded.indexOf('e+') !== -1) {
vRounded = Math.round(v);
} else if(vRounded.lastIndexOf('.') !== -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also e- if the number is <1e-6

Can we do something like:

if(vRounded.indexOf('e') !== -1) {
    vRounded = vRounded.replace(/[.]?0+e/, 'e');
} else if(vRounded.indexOf('.') !== -1) { // why did we have lastIndexOf here? indexOf should be the same, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Revised in 5891651.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! 💃

@archmoj archmoj merged commit 3ab2b93 into master Sep 16, 2020
@archmoj archmoj deleted the fix5122-pie-format branch September 16, 2020 21:58
@archmoj archmoj added this to the v1.56.0 milestone Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pie show incorrect value (in scientific format) when hovered over
2 participants