I am using MPAndroid library for rendering line chart. Everything works fine except the starting point of Y-Axis. I have 0 entry for Y for first two X entries and then for third entry I have some value, Graph start drawing from 0,0 location and not directly from third point. I want graph to start from third point.
How can I do that?
Also on Y axis 0 label is shown, Tried to remove that but couldn't find solution. Tried leftAxis.setStartAtZero(false);
but it doesn't remove 0 label on Y axis and also include a blur line on that point which seems as part of graph
From the documentation, here and here, I think you have two ways to draw what you want.
Limit your Y axis to your value. (User won't be able to scroll below this point)
yourChart.getAxisLeft().setAxisMinValue(yourValue);
Modify ViewPort to fit your needs:
yourChart.moveViewToY(valueCenterOfScreen, YAxis.AxisDependency.LEFT)
To remove '0' from your Y Axis, you should use a custom YAxisValueFormatter:
public class MyYAxisValueFormatter implements YAxisValueFormatter {
private DecimalFormat mFormat;
public MyYAxisValueFormatter () {
mFormat = new DecimalFormat("###,###,##0.0"); // use one decimal
}
@Override
public String getFormattedValue(float value, YAxis yAxis) {
if (value != 0)
return mFormat.format(value);
else
return "";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With