djsiz djsiz - 4 months ago 12
Android Question

Displaying the YAxisRight values to be fixed places , not depending upon the data to be populated

I am trying to implement a Data Consumption Usage Graph in my App, and have been using MPAndroidChart for that. I had done full customisation of the Graph, but the problem is , I am not able to show the YAxisRight Values to be in fixed places ( not depending upon the data to be populated). I wanted to show the YAxisRight Labels in fixed places always even if the dataList is 0 or 100.

BTW I had done YAxisValueFormatter for showing values in range, but that is depending upon the data being populated.

As shown in the figure, the values on YAxisRight should always in fixed place , without depending upon the data being populated!

Thanks for the awesome library MPAndroidChart :)

enter image description here

Answer

Finally, I implemented it . and for others who want to do it.. Its called the LimitLine so you have set the LimitLine to the yAxis.

ex: //showing limit at 2 and 4 in the graph...

LimitLine l = new LimitLine(2f);
//customize you limitline .. lineColor, label text color size etc
l.label = "my limit1";
graph.axisRight.addLimitLine(l);

Limit l1 = new LimitLine(3f);
//customize
l.label = "my limit2";
graph.axisRight.addLimitLine(l1);

Hope it helps someone!

Comments