Skip to content

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

Open

Description

@rben01

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")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions