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
This is how I resolved this issue. It seems like the y axis is always drawn 1 over the max value(if its not force it). So set the label count 2 over the max value(include zero and one over your max) then all you need to do is remove the decimal with the axis formatter. This works if all your y values are integers, not sure how it would work with decimal values.
barChart.getAxisLeft().setLabelCount(maxYvalue + 2, true);
barChart.getAxisLeft().setAxisMinValue(0f);
barChart.getAxisLeft().setAxisMaxValue(maxYvalue + 1);
YAxisValueFormatter customYaxisFormatter = new YAxisValueFormatter() {
@Override
public String getFormattedValue(float value, YAxis yAxis) {
return String.valueOf((int)value);
}
};
barChart.getAxisLeft().setValueFormatter(customYaxisFormatter);