JavaScript formatters for localized numbers and dates.
npm install @d3plus/formatIf using npm, npm install @d3plus/format. Otherwise, you can download the latest release from GitHub or load from a CDN.
``js`
import modules from "@d3plus/format";
In vanilla JavaScript, a d3plus global is exported from the pre-bundled version:
`html`
Live examples can be found on d3plus.org, which includes a collection of example visualizations using @d3plus/react.
#####
* format - An extension to d3's format function that adds more string formatting types and localizations.
* formatAbbreviate - Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. 1200000 to "1.2M").
* formatDate - A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
* formatDefaultLocale - An extension to d3's formatDefaultLocale function that allows setting the locale globally for formatters.
---
#### d3plus.format(specifier) <>
An extension to d3's format function that adds more string formatting types and localizations.
This is a global function
---
#### d3plus.formatAbbreviate(n, locale) <>
Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. 1200000 to "1.2M"`).
This is a global function
---
#### d3plus.formatDate(d, dataArray, [formatter]) <>
A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
This is a global function
---
#### d3plus.formatDefaultLocale(definition) <>
An extension to d3's formatDefaultLocale function that allows setting the locale globally for formatters.
This is a global function
---