How to set increment value for Y axis in MPAndroidChart

I need to change the increment value for the y axis.

I use this code to set min and max:

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

This gives me an idea of ​​the right Y axis:

View of the chart

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

I thought mChart.setVisibleYRange(10, YAxis.AxisDependency.RIGHT); will help me, but it’s not. The same for rightYAxis.mAxisRange = 10; .

Can I customize it? That would be very helpful.

+6
source share
1 answer

Try

yAxis.setLabelCount(19)

This should give you marks from 0 to 180 in increments of 10, provided that you set min to 0 and maximum to 180.

+8
source

Source: https://habr.com/ru/post/986862/


All Articles