Locale API

To display number and date values, by default Vega uses formatting rules for American English. If you are deploying visualizations for other languages you will want to change these defaults.

Vega uses formatting utilities provided by the D3 framework, specifically the d3-format and d3-time-format libraries. These libraries provide methods for updating the default locale and Vega exports these methods as part of its own API.

Note: Application code should set the locale to the desired default before performing parsing and view generation.

Locale Configuration

# vega.formatLocale(definition) <>

Sets the default locale definition for number formatting. This method is an exported version of d3-format’s formatDefaultLocale. See the d3-format locale collection for definition files for a variety of languages.

# vega.timeFormatLocale(definition) <>

Sets the default locale definition for date/time formatting. This method is an exported version of d3-time-format’s timeFormatDefaultLocale. See the d3-time-format locale collection for definition files for a variety of languages.