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

using s format in 0 return 0y #2595

Closed
UlTriX opened this issue Oct 23, 2015 · 3 comments
Closed

using s format in 0 return 0y #2595

UlTriX opened this issue Oct 23, 2015 · 3 comments
Labels
bug Something isn’t working
Milestone

Comments

@UlTriX
Copy link

UlTriX commented Oct 23, 2015

Using d3 version 3.5.6 using s formatter in 0 returns 0y
https://en.wikipedia.org/wiki/Metric_prefix y is yocto

@mbostock
Copy link
Member

I can’t reproduce this issue.

d3.format("s")(0) // "0"
d3.formatPrefix(0) // {symbol: ""}

Also, I’d be curious if you can reproduce this problem in the new d3-format repo, which will be the 4.0 implementation.

@UlTriX
Copy link
Author

UlTriX commented Oct 23, 2015

I forgot to mention that it was d3.format("s")("0") that returned 0y

With other string values works fine. It was not supposed to work with strings?

@mbostock mbostock added the bug Something isn’t working label Oct 23, 2015
@mbostock mbostock added this to the 3.5.7 milestone Oct 23, 2015
@mbostock mbostock reopened this Oct 23, 2015
@mbostock
Copy link
Member

Great, thanks. Fixed the type coercion bug. Generally speaking it’s a bad idea to pass in the wrong type (and d3.format expects a number), but we should coerce to the right type, and I’ve fixed that bug in d3.formatPrefix, and by extension d3.format. Staged for 3.5.7 in #2591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Development

No branches or pull requests

2 participants