How Can I Alter The Spacing For The Y-Axis Labels In MPAndroidchart?
How can I make my YAxis labels elevated with a gap i.e., start from a given value like the below picture? If I try using offset it makes my YAxis label values plot incorrectly agai
Solution 1:
This was achieved through implementing IAxisValueFormatter
because I wanted to keep all values and just modify the labels:
public class MyValueFormatter implements IAxisValueFormatter {
private final float cutoff;
private final DecimalFormat format;
public MyValueFormatter(float cutoff) {
this.cutoff = cutoff;
this.format = new DecimalFormat("###,###,###,##0.00");
}
@Override
public String getFormattedValue(float value, AxisBase axis) {
if (value < cutoff) {
return "";
}
return "$" + format.format(value);
}
}
And then I consume it using:
leftAxis.setValueFormatter(new MyValueFormatter(yMin));
where yMin
was defined earlier:
private float yMin = 0;
and then assigned the chart's minimum yValue was passed in.
Post a Comment for "How Can I Alter The Spacing For The Y-Axis Labels In MPAndroidchart?"