0

I am using Achartengine release 1.1.0. How do I get combined chart with stacked bar graph and line chart? I am able to get a simple bar & line chart by returning an intent as:

String[] types = new String[] { BarChart.TYPE, LineChart.TYPE };
Intent intent = ChartFactory.getCombinedXYChartIntent(context, dataset, renderer, types,
    "Weather parameters");

Now instead of a simple BarChart as above, i would like to use a Stacked bar chart in combination with a line chart. Say I have a stacked bar with a set of 3 lists of values, one way I was able show a stacked bar graph in combination with line chart was by doing something like:

String[] types = new String[] { BarChart.TYPE, BarChart.TYPE, BarChart.TYPE, LineChart.TYPE }
Intent intent = ChartFactory.getCombinedXYChartIntent(context, dataset, renderer, types,
    "Weather parameters");

The y-values of the 2nd and 3rd barcharts had to be updated by adding them to the y-values of the previous barchart to get a stacked effect. Is there a way of using a stacked bar chart directly instead of doing it this way ? I looked at achartengine's SalesStackedBarChart example, they get a stacked bar by returning the following intent:

return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
    Type.STACKED)

However I cannot figure how to use the Type.STACKED with ChartFactory.getCombinedXYChartIntent(..)

  • http://stackoverflow.com/questions/23102302/combination-of-two-bar-chart-and-two-line-chart-using-achartengine-in-android – keshav May 27 '14 at 11:10

1 Answers1

0

If you want is

String[] types = new String[] { BarChart.TYPE, BarChart.TYPE, BarChart.TYPE, LineChart.TYPE }

To be BarChart.Stacked? It is not possible. Only the primitive graphics have the type attribute. In that case you will need something like StackedBarChart as a class that does not exist.

You have to combined like in the example that keshav post.

Juan Acosta
  • 371
  • 3
  • 10