I am using MPAndroidChart
library version 2.2.4
. My requirement is I want to set three marker lines in a BarChart
with values "Minimum", "Average" and "Maximum" like in the image below, but I can't find any solution for this.
Asked
Active
Viewed 9,071 times
12

David Rawson
- 20,912
- 7
- 88
- 124

Neha Shukla
- 3,572
- 5
- 38
- 69
1 Answers
21
In MPAndroidChart 3.x.x what you are asking for is called a LimitLine
There is an example of how to consume it in the sample project:
LimitLine ll1 = new LimitLine(150f, "Upper Limit");
ll1.setLineWidth(4f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLabelPosition.RIGHT_TOP);
ll1.setTextSize(10f);
ll1.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.addLimitLine(ll1);
If you require a customized limit line, you will have to look at the instructions in this question here

David Rawson
- 20,912
- 7
- 88
- 124
-
1Thanks its looking good here i add one more property for identifying the line with custom color use this `ll1.setLineColor(getContext().getResources().getColor(R.color.your_color)); ` – Arbaz.in Oct 08 '21 at 03:58
-
How to fill color for area between LowerLimitLine and UpperLimitLine ? – K Pradeep Kumar Reddy Jun 09 '22 at 16:45