This is my list of my BarEntry On MPAndroidChart:v3.0.3

as you can see its values on 3 index of array. My question is why when these values shows on chart their values is rounded ?

this my codes:
barEntriesCur.add(new BarEntry(1, (float) Double.parseDouble(incomeModel.getIncome_Payable_Cur()) / 1000000));
barEntriesCur.add(new BarEntry(2, (float) Double.parseDouble(incomeModel.getNosazi_Payable_Cur()) / 1000000));
barEntriesCur.add(new BarEntry(3, (float) Double.parseDouble(incomeModel.getSenfi_Payable_Cur()) / 1000000));
barEntriesPre.add(new BarEntry(1, (float) Double.parseDouble(incomeModel.getIncome_Payable_Pre()) / 1000000));
barEntriesPre.add(new BarEntry(2, (float) Double.parseDouble(incomeModel.getNosazi_Payable_Pre()) / 1000000));
barEntriesPre.add(new BarEntry(3, (float) Double.parseDouble(incomeModel.getSenfi_Payable_Pre()) / 1000000));
BarDataSet barDataSet = new BarDataSet(barEntriesCur, "cur");
barDataSet.setColors(AXisValueFormatter.SAFACUSTOM_COLORS2);
BarDataSet barDataSet1 = new BarDataSet(barEntriesPre, "pre");
barDataSet1.setColors(AXisValueFormatter.SAFACUSTOM_COLORS3);
BarData data = new BarData(barDataSet, barDataSet1);
mBinding.barChartReport.setData(data);
float groupSpace = 0.20f;
float barSpace = 0.02f;
float barWidth = 0.35f;
data.setBarWidth(barWidth);
data.setValueTextSize(10f);
mBinding.barChartReport.groupBars(1, groupSpace, barSpace);
mBinding.barChartReport.getAxisLeft().setStartAtZero(true);
mBinding.barChartReport.setPinchZoom(false);
mBinding.barChartReport.setBackgroundColor(Color.TRANSPARENT);
mBinding.barChartReport.setDrawGridBackground(false);
mBinding.barChartReport.getDescription().setEnabled(false);
mBinding.barChartReport.setFitBars(true);
mBinding.barChartReport.invalidate();
Implemented your code and here is solution. But first explanation: This happens because values are in big range, you have 5595 and 590 on the same Graph, so default value formatter removes decimals, because it thinks it is not important.
Solution is to implement your custom formatter:
public class MyDecimalValueFormatter implements IValueFormatter {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return String.valueOf(value);
}
}
And then set it to dataset:
data.setValueFormatter(new MyDecimalValueFormatter());
Tested with your code and it works (with your data):

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With