Search code examples
androidachartengineandroid-graphview

How to add target line in Line chart - AChartEngine


Is there any way I can add a target line in a Line Chart?

I want to draw green line shown in bar char image.

Thanks in advance.

Target line image


Solution

  • I found the answer.

    We can use combinechart to get the target line.

    // Specifying chart types to be drawn in the graph
    // Number of data series and number of types should be same
    // Order of data series and chart type will be same
    String[] types = new String[] { LineChart.TYPE, BarChart.TYPE };
    
    ChartFactory.getCombinedXYChartView(getBaseContext(), dataset, multiRenderer, types);
    

    This will create chart with Line chart and Bar chart.

    Tutorial : http://wptrafficanalyzer.in/blog/android-combined-chart-using-achartengine-library/