apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js
https://apexcharts.github.io/Blazor-ApexCharts
MIT License
788 stars 91 forks source link

fix: use JsonElement.TryGetDecimal to format the YAxis value. #367

Closed meronz closed 8 months ago

meronz commented 8 months ago

This is done to avoid decimal parsing issues when applications set a non-US culture that use a different decimal separator (such as it-IT).

Bug info

I reproduced this bug on Blazor WASM, this has been present for a long time (Blazor-ApexCharts v1.x). If the application sets the current culture to a culture that does not use the dot . as the decimal separator, then the decimal passed to the FormatYAxisLabel callback has all the decimals removed. Ex. the value 1.23 becomes 123.

I fixed it by not relying on decimal.Parse but on the JsonElement.TryGetDecimal method, that works correctly regardless of the current culture.

 Steps to reproduce:

meronz commented 8 months ago

Bad commit email and name, i will reopen it.