Reputation: 5932
I created a bar chart by MPAndroidChart:v3.0.3
.as you can see on my picture
On AxisLeft, there are a big numbers. this is my codes:
YAxis yAxis = mBinding.barChartIncome.getAxisLeft();
yAxis.setDrawGridLines(true);
yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
yAxis.setSpaceTop(15f);
yAxis.setTextSize(12f);
yAxis.setAxisMinimum(1f);
yAxis.setLabelCount(10, false);
Now, I want to dived these big numbers into 1,000,000 and then shown on chart?How could i do that?
Upvotes: 2
Views: 975
Reputation: 13057
You need IAxisValueFormatter
for this. Create class that implements it like this:
public class MyYAxisValueFormatter implements IAxisValueFormatter {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return String.valueOf(value/1000000); // Format value, and get any string here
}
}
And set it to your chart's Left axis :
chart.getAxisLeft().setValueFormatter(new MyYAxisValueFormatter());
Upvotes: 2