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

Specify type g decimal to exponential break point #137

Open
janosh opened this issue Apr 3, 2023 · 0 comments
Open

Specify type g decimal to exponential break point #137

janosh opened this issue Apr 3, 2023 · 0 comments

Comments

@janosh
Copy link

janosh commented Apr 3, 2023

Is there a to specify at how many decimal places type g switches from decimal to exponential?

I'd like to format everything with more than 3 decimal places as exponential:

expect(d3.format('.3~g')(0.1)).toBe('0.1')
expect(d3.format('.3~g')(0.01)).toBe('0.01')
expect(d3.format('.3~g')(-0.001)).toBe('-0.001')
expect(d3.format('.3~g')(-0.0001)).toBe('−1e-4') // actual: −0.0001
expect(d3.format('.3~g')(-0.00001)).toBe('−1e-5') // actual: −0.00001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant