Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MpAndroidChart set background between limit lines

I a using MpAndroidChart library. I need to implement a design where I need to color the area between two limit lines. I have attached an image for reference. I have tried multiple ways but I have failed to achieve it. I am using this library for the first time. Can anyone help me about how this could be achieved. As you can see the green shade behind the line graph. Which is the limit. I need to get that green shade

As you can see the green shade behind the line graph. Which is the limit. I need to get that green shade

Thanks in advance,

Anudeep Reddy.

like image 481
Anudeep Avatar asked Apr 29 '26 01:04

Anudeep


1 Answers

I don't think that there is a direct way to achieve this, but this workaround should help you:

LimitLine ll = new LimitLine(lowerLimit, "Systolic range");
ll.setLineColor(Color.GREEN);
ll.setLineWidth(upperLimit - lowerLimit);

ll.setTextColor(Color.WHITE);
ll.setTextSize(12f);

chart.getAxisLeft().setDrawLimitLinesBehindData(true);

The important thing here is the method setDrawLimitLinesBehindData(true).

As always, all the information is available in the documentation.

like image 165
Harsh Pandey Avatar answered May 01 '26 14:05

Harsh Pandey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!