0

How to combine line chart and bar chart on the one plot? The documentation does not mention about this functionality. Is this possible for AndroidPlot?

1 Answers1

0

Use this in oncreate() of ur activity.

setContentView(R.layout.main);
    XYPlot plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);

    Number[] series1Numeros = { 1, 8, 5, 2, 7, 4 };
    XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numeros), 
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Intereses");

    XYSeries series = new SimpleXYSeries(Arrays.asList(new Number[] { 1, 2, 3, 4, 5 }),
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "title");
    BarFormatter formatter = new BarFormatter(Color.rgb(0, 200, 0), Color.rgb(100, 0, 0));
    plot.addSeries(series, BarRenderer.class, formatter);
    BarRenderer renderer = (BarRenderer) plot.getRenderer(BarRenderer.class);
    LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.rgb(0, 200, 0),
            Color.rgb(0, 100, 0),
            null); 

    plot.addSeries(series1, series1Format);
keshav
  • 3,235
  • 1
  • 16
  • 22