Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw vertical line in the middle of a line chart (indicator)

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.

like image 290
Moonlit Avatar asked Mar 12 '15 10:03

Moonlit


People also ask

How do you draw a vertical line in Chartjs?

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 .


1 Answers

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!

like image 70
Philipp Jahoda Avatar answered Oct 05 '22 07:10

Philipp Jahoda