使用achartengine的动态图表

时间:2012-05-25 10:45:46

标签: android dynamic charts achartengine

我的应用程序通过蓝牙连续接收来自设备的数据,具体取决于绘制图形所需的数据。我发现achartengine在绘制图表时非常有用,现在我的问题是如何使用achartengine创建动态图形,是吗可能?。如果不是我该怎么办

提前感谢。

5 个答案:

答案 0 :(得分:6)

我使用随机数作为输入/数据,而不是蓝牙的实际输入。可以找到完整的工作项目here,认为它可以帮助某人。:)

欢呼声。

答案 1 :(得分:2)

因此AchartEngine不会管理动态或我们称之为实时绘图的内容,但您可以通过在向您的系列添加新数据时连续刷新图表来实现此目的:

private GraphicalView mChartView;// that's your graph view declared before

if (mChartView != null) {

mChartView.repaint();// to refresh the graph 

 }

在序列化循环中创建代码或在需要刷新图形的位置。

答案 2 :(得分:2)

但是你必须在生成或重绘之前删除上一个图形()所以这样做会对你有所帮助。

private GraphicalView mChartView;// that's your graph view declared before

if (mChartView != null) {
layoutr.removeView(mChartView);

mChartView.repaint();
layout.addView(mChartView);// to refresh the graph 

}

答案 3 :(得分:0)

如果你在模拟器中测试动态图形,请尝试在真实设备中进行测试,因为有时模拟器不能正确响应,因此它会浪费大量宝贵的时间。

private GraphicalView mChartView;// that's your graph view declared before

if (mChartView != null) {
layout.removeView(mChartView);//Delete the old graph 

mChartView.repaint();// to refresh the graph 

}

答案 4 :(得分:0)

只要当前 GraphicalView 未从布局中删除并再次重新添加,图形就不会刷新。 否则,只有触摸包含“GraphicalView”的布局才能刷新图形(通过 onTouch 回调)。