apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.2k stars 19.61k forks source link

[Feature] Can we freely decide between thousandSeparator and decimalSeparator? #18707

Open faner11 opened 1 year ago

faner11 commented 1 year ago

What problem does this feature solve?

I am a developer serving the Brazilian market, where thousandSeparator is '.' , decimalSeparator is ',', now it is possible to use formatter to reach the target, but it is not possible to configure it globally, which is a pain

https://github.com/apache/echarts/blob/master/src/util/format.ts#L32

What does the proposed API look like?

const opts = { formatterConfig: { thousandSeparator: ',', decimalSeparator: '.', }, }

helgasoft commented 1 year ago

Try registerLocale with /src/i18n/langPT-br.ts ?

faner11 commented 1 year ago

Try registerLocale with /src/i18n/langPT-br.ts ?

Yes, langPT-br.ts is just a copywriting change, but the actual number display is still the standard in English, for example the number "1,000.99", in Brazil would be written as '1.000,99', I hope to achieve this effect

helgasoft commented 1 year ago

How about this Demo Code ? image

faner11 commented 1 year ago

How about this Demo Code ? image

Yes, but this requires specifying the formatter in each place where it is used, which is painful to maintain when there are many charts, so I hope there is a global configuration place