Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart how to draw y-axis limit line and set view point to bottom

MPAndroidChart is very awesome library.I am very thankful to. But now, I have 3 problems.

The version I used is...

    compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'

And my problem is,...

Left: now -> Right: want to be enter image description here

1. How to draw limit a Y value line on line chart or bar chart?

e.g. I want to draw value y=200 line on Image. (e.g. attached image top.shown in red)

2. How to set viewpoint to bottom and get y-axis mint limit to bottom value? (e.g. attached image bottom) I want to set viewpoint to bottom. I tried this code ,But still,there is some padding.

    XAxis xAxis = mBarChart.getXAxis();
    xAxis.setAxisMinValue(0);

I want to trim this padding.

*Edited

This works well. Thank you!

    mChart.getAxisLeft().setAxisMinValue(0); 

3.How to remove point of graph on line chart?

A line chart, the bottom image, has lots of marker. So I want to remove these plot point.

like image 668
user3569065 Avatar asked Jul 10 '16 17:07

user3569065


1 Answers

1) You need to add a LimitLine

int maxCapacity = 100;
LimitLine ll = new LimitLine(maxCapacity, "Max Capacity");
chart.getAxisLeft().addLimitLine(ll);

You can also style the line by:

ll.setLineWidth(4f);
ll.setTextSize(12f);

2) This method may be useful:

chart.setViewPortOffsets(float left, float top, float right, float bottom);

You can read the documentation here.

3) This method is what you need:

lineDataSet.setDrawCircles(false);

Once again, its all available in the documentation.

like image 154
Harsh Pandey Avatar answered Sep 28 '22 15:09

Harsh Pandey