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

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.

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!

You can draw verctical lines on your graphic using Highlight class. See https://stackoverflow.com/a/42852833/4361772

Related

Is it possible to pick and choose which y-label values inside a linechart of mpandroidchart are displayed?

Below is the chart I am trying to create using MPAndroidChart library:
required_graph
To create this graph, I need some way to tell the linechart to only show two y-values "Average" and "You". I also need a way to draw a vertical grid-line that only goes up to the circle/y-value. I have searched for tutorials, SO articles, issues on MPAndroidChart github as well as the wiki, but I'm still uncertain how to create the graph above. Is there a way to create this graph with MPAndroidChart? Any help is much appreciated.
Try creating multiple data sets and style them differently. The 1st one should contain all the values, including "Average" and "You", enable fill color and disable drawing the circles.
Then, create a new set with a single value (average) and give it a different style. Do the same with the "you" value.
Good luck !

achartengine: line chart with threshold

I use achartengine in my Android application and has been able to draw few line charts. Now I need to draw some kind of threshold line which basically an extra line in red that will run at certain Y value across the graph.
I read other questions regarding threshold lines but mostly about bar chart to have different color above and below threshold line. I need it for line chart and I don't need different color above and below the threshold line.
I can definitely draw it as another line, but I don't want legend for this shows up while I still want legend for others show up. Is there any way to do this? I don't know if there is built-in functionality to draw the threshold line. Or at least a way to hide legend for only one line.
Any input, suggestion or direction will be very appreciated. Thank you.
Got it. If anyone needs to do the same thing, this is what I do:
if(i == theIndexForThresholdLine) {
renderer.getSeriesRendererAt(i).setShowLegendItem(false);
}
That will turn off legend only for that item.

How to put crosshairs (vertical line) in line graph using achartengine in android

I am using achartengine graph library for line chart in android. Can some one advice me on putting crosshairs (A vertical line which moves on all data points when user touches on the graph) My requirements match to a implementation like this http://www.jqchart.com/samples/ChartFeatures/Crosshairs or there is another library available that can be implemented easily in android for vertical line cross hair.
you will able to accomplish the task by adding an onClickListener on the chart and when a valid point is detected you add another drawable on top of the chart. Keep the chart in a frameLayout and add that drawable in the form of imageView and show/hide the imageView on certain events as per your requirement.
edit:also in your case you will need to modify the height of the drawable everytime

Draw chart with different color positive and negative values in achartengine

I am trying to create a line/area chart using achart library, my usecase is to show the chart as green above the predefined point and show the chart as red below the predefined point.
Please help. Please refer the sample chart
You can create two separate series, one to display the line above zero and the second one for the one below.

AchartEngine Android Special Pie Chart

I'm using the AchartEngine libraries to make a pie chart app. But I want to display two dimensional data like this
I can get nice standard pie charts but I know how to do the second dimension. Can anyone please help? The guys on the achartengine-google-support group say it's possible but I was redirected here for tech questions.
Many Thanks
If you take a look at the Budget Pie chart demo it shows you how to highlight a section of your pie chart (https://code.google.com/p/achartengine/source/browse/trunk/achartengine/demo/org/achartengine/chartdemo/demo/chart/BudgetPieChart.java). Take a look at "Project 1" below to see how this looks.
However there is no way to change the radius like you want to in your screenshot above. If you want to achieve this the easiest way would be to extend PieChart and copy over the draw method. In the draw method where it renders highlighted sections (if (seriesRenderer.isHighlighted()) ...) use a different radius instead of translating to an offset.

Categories

Resources