使用Achartengine多个堆叠条形图可能吗? [英] Are multiple stacked Bar charts possible using Achartengine?

查看:129
本文介绍了使用Achartengine多个堆叠条形图可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试添加另一组值的<一个演示示例href="http://www.androidadb.com/source/achartengine-read-only/achartengine/demo/org/achartengine/chartdemo/demo/chart/SalesStackedBarChart.java.html"相对=nofollow>堆积条形图与achartengine 的,但我所提出不显示在图表上的新值。作为堆叠酒吧限于两杠?

 公共意向getIntent(上下文的背景下){

    的String []标题=新的String [] {好,缺陷,修复};
    名单&LT;加倍[]&GT;值=新的ArrayList&LT;加倍[]&GT;();

    values​​.add(新的双[] {14230,12300,1424,15240,15900,19200,
    22030,21200,19500,15500,12060,14000});
    values​​.add(新的双[] {14230,12300,14240,15244,15900,19200,
            22030,21200,19500,15500,12600,14000});
    values​​.add(新的双[] {5230,7300,9240,10540,7900,9200,12030,
            11200,9500,10500,11600,13500});

    INT []颜色=新INT [] {Color.GREEN,Color.YELLOW,Color.RED};

    XYMultipleSeriesRenderer渲染= buildBarRenderer(颜色);

    setChartSettings(渲染器,机器使用率,
            机器,纯产品,0.5%,12.5,0,24000,Color.GRAY,
            Color.LTGRAY);

    renderer.getSeriesRendererAt(0).setDisplayChartValues​​(真正的);
    renderer.getSeriesRendererAt(1).setDisplayChartValues​​(真正的);
    renderer.getSeriesRendererAt(2).setDisplayChartValues​​(真正的);
    renderer.setXLabels(12);
    renderer.setYLabels(5);
    renderer.setXLabelsAlign(Align.LEFT);
    renderer.setYLabelsAlign(Align.LEFT);
    renderer.setPanEnabled(真,假);
    renderer.setZoomEnabled(真正的);
    renderer.setZoomRate(1.1F);
    renderer.setBarSpacing(0.5F);
    返回ChartFactory.getBarChartIntent(背景下,
            buildBarDataset(标题,值),渲染器,Type.STACKED);

}
 

解决方案

有一个在路上AChartEngine显示堆积条形图一种误解。它并没有真正堆叠在一起,但它们显示了另一种。这意味着你将要随时添加更大的价值第一次那么小,等等,因为它呈现的第一个系列,第二个上述第一等。

更新:由于1.2.0版本,有新的堆积条形图,其显示在您需要的方式

I tried adding another set of values to the demo example of stacked bar charts with achartengine, but the new values introduced by me don't appear on the chart. Is Stacking bars limited to two bars?

public Intent getIntent(Context context) {

    String[] titles = new String[] { "Good", "Defect", "Repair" };
    List<double[]> values = new ArrayList<double[]>();

    values.add(new double[] { 14230, 12300, 1424, 15240, 15900, 19200,
    22030, 21200, 19500, 15500, 12060, 14000 });
    values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200,
            22030, 21200, 19500, 15500, 12600, 14000 });
    values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030,
            11200, 9500, 10500, 11600, 13500 });

    int[] colors = new int[] { Color.GREEN, Color.YELLOW, Color.RED };

    XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);

    setChartSettings(renderer, "Machine Efficiency Rates",
            "Machine", "NET produce", 0.5, 12.5, 0, 24000, Color.GRAY,
            Color.LTGRAY);

    renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
    renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
    renderer.getSeriesRendererAt(2).setDisplayChartValues(true);
    renderer.setXLabels(12);
    renderer.setYLabels(5);
    renderer.setXLabelsAlign(Align.LEFT);
    renderer.setYLabelsAlign(Align.LEFT);
    renderer.setPanEnabled(true, false);
    renderer.setZoomEnabled(true);
    renderer.setZoomRate(1.1f);
    renderer.setBarSpacing(0.5f);
    return ChartFactory.getBarChartIntent(context,
            buildBarDataset(titles, values), renderer, Type.STACKED);

}

解决方案

There is a misunderstanding in the way AChartEngine displays stacked bar charts. It doesn't really stack them, but displays them one over the other. This means that you will want to always add the bigger values first then the smaller and so on as it renders the first series, the second one above the first and so on.

UPDATE: As of version 1.2.0, there is the new HEAP stacked bar charts, which are displayed in the manner you need.

这篇关于使用Achartengine多个堆叠条形图可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆