Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set increment value for Y axis in MPAndroidChart

I need to change increment value for Y axis.

I'm using this code to set min and max:

YAxis rightYAxis = chart.getAxisRight();
rightYAxis.setAxisMaxValue(180);
rightYAxis.setAxisMinValue(0);

It gives me this view of the right Y axis:

View of the chart

Y axis shows [0, 30, 60, ..., 180] so increment here is 30. But I need to set increment equal 10. So I want to see [0, 10, 20, ..., 180].

I thought that mChart.setVisibleYRange(10, YAxis.AxisDependency.RIGHT); will help me, but it didn't. The same for rightYAxis.mAxisRange = 10;.

Is it possible to set it up? It would be very useful.

like image 622
Anton Holovin Avatar asked May 09 '15 12:05

Anton Holovin


1 Answers

Try

yAxis.setLabelCount(19)

This should give you labels from 0 to 180 in steps of 10, assuming you set min to 0 and max to 180.

like image 156
Philipp Jahoda Avatar answered Sep 23 '22 03:09

Philipp Jahoda