0

我有一个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存储我想要的一些信息的类。

我附上了一张图片,进一步描述了我的问题。

在 800 次通过后绘制一条线...

4

1 回答 1

0

我解决了这个问题;我忘了执行

graphView.setViewPort(3, 6);

setViewPort窗口限制为特定数量的数据。

于 2014-04-22T15:41:26.523 回答