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

[Request] Get the current/default locale definition when passing no argument to formatLocale #110

Open
rben01 opened this issue Feb 1, 2021 · 0 comments

Comments

@rben01
Copy link

rben01 commented Feb 1, 2021

Many d3 functions use the presence of an argument to control their behavior -- if an argument is passed, it used to update the object, and if it's missing then the current value is returned. For instance d3.scaleLinear().domain([0,1]) vs d3.scaleLinear().domain().

It would be handy if d3.formatLocale could be used this same way in order to return the current locale settings (likely the defaults if the user hasn't called d3.formatDefaultLocale) so that the user could modify just one of them before passing the updated definition list back to d3.formatLocale. For instance,

const definition = d3.formatLocale();
definition.minus = "-"  // Replace the default unicode minus character with a hyphen
// Leave everything else, such as commas and the decimal separator, as the en-US default
const formatter = d3.formatLocale(definition).format(",.2f")
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