I am using a chart library called MPAndroidChart and I am very pleased with it. However, I want to draw a thick vertical line (as a background, not as data) serving as an indicator in the the middle of the line graph. How can I do this?
Best regards.
Use a combo bar / line chart, and use the bar chart to draw the vertical lines. Use two y-axes: one for the bar chart (which we don't display), and one for all your other line chart datasets. Force the bar chart y-axes to min: 0 and max: 1 .
You can use the LimitLine
class to acheive this.
Basically, that class allows you to draw a customizeable line to a specified position on the y-axis in the chart and add a description to it.
After creating the line, you need to assign it to an XAxis
or YAxis
.
For more details, have a look at the documentation. You can find limitlines it on the bottom of the page.
Also, this example class shows how to use them: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java
UPDATE: Now LimitLines can be assigned to any axis!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With