I\'ve created a BarChart using MPAndroidChart and I\'m entering the data dynamically. This means that I need my Y axis to also be determined dynamically. All of my data is repre
Pretty simple. All you need is two things:
Axis value formatter
mChart.getAxisLeft().setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return String.valueOf((int) Math.floor(value));
}
});
Axis label count
int max = findMaxYValue(yourdata); // figure out the max value in your dataset
mChart.getAxisLeft().setLabelCount(max);
My Solution:
mChart.getAxisLeft().setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return String.valueOf((int) Math.floor(value));
}
});
int max = (int) mChart.getData().getYMax();
mChart.getAxisLeft().setLabelCount(max);