ChartJs localizes numbers by default
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
I use ChartJS with Angular (12.2.17). Angular by default uses localization en_US for number formatting. ChartJS has not documented what is the default locale, so I assumed it has a forced default locale as well.
### Current behavior
Most of the countries use comma as thousand separator, and dot as decimal character. German way of formatting numbers is the dot as the thousand separator, and comma as decimal character. ChartJS uses the browsers language and/or location as the default number formatting. That results having the same data in two different formats, when I need both chart and a list implemented in Angular. Depending on the dataset, it might not be clear that two different formats are in use, and for example 1,111 could mean either decimals or thousands.
It is possible to set the locale in Angular based on users language, but the problem is that each of the locales has to be registered in build-time with registerLocaleData, otherwise all Angular number pipes will fail. It is not efficient to register every single language in the world, it will increase the build size. Even if I register a subset of languages that users will most likely use and set a fallback, ChartJS would still by default use the location based formatting for the languages outside of the list.
### Reproducible sample
https://angular-chart-js-6yfyzw.stackblitz.io
### Optional extra steps/info to reproduce
Change your browser language to German -> Angular table is not converted to German numbers, in the chart numbers are converted.
Browser language English -> same format in both.
### Possible solution
I think at minimum you should document that ChartJS numbers are localized by default, so that users know they have to manually write the locale for the charts. It is still a very unexpected consequence, no one who doesn't provide automatic location-based translations, would think of testing the app with different languages. That's why not localizing numbers by default would be much clearer use case.
### Context
_No response_
### chart.js version
4.0.1
### Browser name and version
_No response_
### Link to your project
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.