我有一个GraphView
来自以下GitHub 库。
当我使用他们对GraphView RealTimeGraph
. 它正在根据所有先前的数据绘制一条线。即它正在寻找一条趋势线并绘制一条直线;当它应该从先前附加的数据到新附加的数据绘制一条线时。
相关代码:
public void pauseGraphUI() {
mHandler.removeCallbacks(mTimer1);
mHandler.removeCallbacks(mTimer2);
}
public void updateGraphUI() {
mTimer1 = new Runnable() {
@Override
public void run() {
globalData.getGraphViewSeries().resetData(
new GraphViewData[] {
new GraphViewData(1, getRandom()),
new GraphViewData(2, getRandom()),
new GraphViewData(3, getRandom()),
new GraphViewData(4, getRandom()),
new GraphViewData(5, getRandom()),
new GraphViewData(6, getRandom()) });
mHandler.postDelayed(this, 500);
}
};
mHandler.postDelayed(mTimer1, 500);
mTimer2 = new Runnable() {
@Override
public void run() {
globalData
.setGraph2LastXValue(globalData.getGraph2LastXValue() + 1);
globalData.getGraphViewSeries().appendData(
new GraphViewData(globalData.getGraph2LastXValue(),
getRandom()), true, 10);
mHandler.postDelayed(this, 500);
}
};
mHandler.postDelayed(mTimer2, 1000);
}
GlobalData 只是一个Singleton
存储我想要的一些信息的类。
我附上了一张图片,进一步描述了我的问题。