Search code examples
amcharts

Formatting numbers with thousand separator as empty string on amcharts4


I need to format the chart number format so that numbers stop looking like that 1,525 (comma separator) and start looking like this 1 525 (empty string thousand separator). Plus, I need dot separator for decimal, but only if a number has any, like this 1 525.4 The closest number format I was able to find for amCharts4 version is

chart.numberFormatter.numberFormat = '#,###.#';

Any ideas?


Solution

  • So, after a research I've found a solution - you have to use locales.

    This line of code helped me a lot:

    chart.language.locale = am4lang_[locale];
    

    For empty string separator I used am4lang_ru_RU.

    Btw, if you need to make your own number, strings, etc formatting, you can create your locales for that.