2

我是安卓新手。我正在进行一个项目并尝试绘制堆积条形图。我对这种条形图做了很多研究,但要么这些都不起作用,要么我无法将代码应用到我的项目中。我想有两个最流行的图表库是 AChartEngine 和 Charts4j。我检查了此代码(https://code.google.com/p/charts4j/source/browse/tags/v1.2/example/com/googlecode/charts4j/BarChartExample.java#51)- Charts4j 的 example1。但是,此代码以 'url' 结尾,我的项目中有我的值,我将使用这些值来绘制图表,并且我不希望有互联网来显示图表。我想独立于互联网。我无法将此代码实施到我的项目中。

我使用的另一个库是 AChartEngine,我找到了这段代码(https://code.google.com/p/achartengine/source/browse/trunk/achartengine/demo/org/achartengine/chartdemo/demo/chart/SalesStackedBarChart.java) . 因为主类扩展了其他类,所以我创建了其他类(AbstractDemoChart)和接口(IDemoChart)并编写了代码。Eclipse 没有给出任何错误,但是当我在 Emulator 上运行它时,我收到一个错误,导致应用程序停止并且出现“强制关闭”警告。

关于条形图的其他示例与我想要的完全不相关。结果,我找不到任何适合我的应用程序的解决方案。您能帮我如何使用我已经拥有的值为我的 Android 应用程序绘制堆积条形图,并且我想独立于互联网查看此图表吗?

提前谢谢各位。

4

3 回答 3

1

我建议您下载 AChartEngine 演示源代码并查看SalesStackBarChart。然后,在最后一行,您可以更改Type.STACKEDType.HEAP以获得更好的堆叠条形图体验。

于 2014-02-15T09:06:55.300 回答
1

Androidplot 也支持堆叠条形图。来自 Play 商店的Androidplot 演示应用的屏幕截图:

在此处输入图像描述

于 2014-01-20T15:04:59.870 回答
1

i don't know native android library or extensions to do that, can be difficult to find a good one ore implement a new other. For this i think that you have just used a library HTML/CSS/Javascript.

I think that you can implement with a js library the graph, for example Javascript graph , charge the html/js files in assets and charge it into a web view with this:

html app in android

The only problem is to find a way to pass data to the html, i think that is it possibile in various way, with bridge or using files.

于 2014-01-20T14:55:44.050 回答