I have a GraphView
from the following GitHub library.
When I use their demonstration of GraphView RealTimeGraph
, I get it all to work fine and dandy except for one caveat. It is drawing a line based off of all previous data. I.e. it is finding a trendline and drawing a single straight line; when it should be drawing a line from the previously-appended data to the newly-appended data.
Relevant code:
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 is just a Singleton
class that stores some information I want.
I've attached an image describing my problem further.