user3569065 user3569065 - 1 year ago 235
Java Question

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

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)

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();

I want to trim this padding.


This works well. Thank you!


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.

Answer Source

1) You need to add a LimitLine

int maxCapacity = 100;
LimitLine ll = new LimitLine(maxCapacity, "Max Capacity");

You can also style the line by:


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:


Once again, its all available in the documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download