MPAndroidChart
MPAndroidChart copied to clipboard
Value Formatting is not done correctly. e00 is added at the last
@PhilJay can you look into it. For value formatting, we use Decimal Formatter with a pattern, and symbols are not added.
- During Language change in the Application, the numbers should not change the Format. But it is changing for some Languages.
Solution: Add Symbols parameter using DecimalFormatSymbols. or add an extra parameter to add by the user.

- In Some Devices, while using LargeValueFormatter to make it pretty in the code written by Roman Gromov the patter "###E00" is returning the end with e00 and Further String operations are not done as expected.
Solution : Replace regex can be changed to "[E|e][0-9][0-9]". If this is used then the Language Change Cannot be done as we get the regex in the other language formats.

you can custom like this
class ChartNumberFormat : ValueFormatter() {
override fun getFormattedValue(
value: Float
): String {
// Menggunakan long untuk angka yang lebih besar dari int
val trillion = 1000000000000L // Miliaran
val billion = 1000000000L // Miliaran
val million = 1000000L // Juta
val thousand = 1000L // Ribu
return if (value >= trillion) {
String.format(Locale("in", "ID"), "%.2f T", value / trillion) // Format untuk trillion
} else if (value >= billion) {
String.format(Locale("in", "ID"), "%.1f B", value / billion) // Format untuk miliaran
} else if (value >= million) {
String.format(Locale("in", "ID"), "%.0f M", value / million) // Format untuk juta
} else if (value >= thousand) {
String.format(Locale("in", "ID"), "%.0f K", value / thousand) // Format untuk ribuan
} else {
value.toInt().toString() // Format untuk angka di bawah ribuan
}
}
}
and add ChartNumberFormat to valueFormatter
val leftAxis: YAxis = chart.axisLeft
leftAxis.textSize = 12f
leftAxis.valueFormatter = ChartNumberFormat()
leftAxis.axisMinimum = 0f // this replaces setStartAtZero(true)
leftAxis.textColor = getColor(requireActivity(), R.color.black_color)
leftAxis.granularity = 1.0f
leftAxis.isGranularityEnabled = true