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 represented as integers, however the Y axis is sometimes displaying the legend as decimal values with 1 decimal point.
I've attempted to use a ValueFormatter to round the values, but the problem is that sometimes the Y values aren't at integer value locations (ex. 0.8,1.6,2.4,etc). Therefore, if I just edit these to be integers they won't be in the right location.
Is there anyway that I can force the BarChart to only display values at Integer locations? Its ok if it skips some, in fact I want it to when the values get large.
Edit: When I said that the integers aren't in the right locations, I meant that once I modify what each label displays they aren't 'correct'. In my example I have 5 bars displaying the values 3,4,2,3,2. The first image is the 'default', the second is the image once I've edited the value formatter using:
public String getFormattedValue(float v)
return ((int) v)+"";
Allright, now I see your problem.
THe problem is that the
YAxis (YLabels) determines the number of digits and thus the steps between each label automatically.
Unfortunately it's currently not possible to customize how the axis computes itself or set custom labels.
I am considering to add such a feature in the future, where the user can self define which values are drawn as the axis labels.
Just a hint:
mEntries array that holds all the axis labels is public. So in general, you could modify it after it has been created.
However, I am absolutely not sure how the axis will behave if you manually modify it.
But maybe its worth a try :-) https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/com/github/mikephil/charting/components/YAxis.java