I use MPAndroidChart to display the stock chart, but the Y line value is so close,the chart is like this
I can use finger zoom like this way
Which is I want the default looks like
Is there any way to set Y line max and min value or set default zoom.
I tried the lib function , but it does not work
Take a look at the documentation of the YAxis. There are various methods that allow you to control the axis range.
setStartAtZero(boolean enabled)
: If this is enabled, this axis will always have it's minimum value at zero (0), no matter which kind of data the chart displays.setAxisMaxValue(float max)
: Set a custom maximum value for this axis. If set, this value will not be calculated automatically depending on the provided data. setAxisMinValue(float min)
: Set a custom minimum value for this axis. If set, this value will not be calculated automatically depending on the provided data. setSpaceTop(float percent)
: Sets the top spacing (in percent of the total axis-range) of the highest value in the chart in comparison to the highest value on the axis. setSpaceBottom(float percent)
: Sets the bottom spacing (in percent of the total axis-range) of the lowest value in the chart in comparison to the lowest value on the axis. There is a kind of dependency between left and right axises. I had only right axis enabled and set
chart.getAxisRight().setStartAtZero(false);
but that didn't work till I set the same parameter to my leftYAxis, which was disabled. So I have now
chart.getAxisLeft().setStartAtZero(false);
chart.getAxisRight().setStartAtZero(false);
edit:
setStartAtZero is deprecated, the code recommends using setAxisMinimum instead.
* This method is deprecated.
* Use setAxisMinimum(...) / setAxisMaximum(...) instead.
You can find more on that in the documentation.
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