Hi!
I'm using the library to dynamicaly display new data in a line chart. I implemented the adding of values based on the RealTimeLineChart example, but I'm worrying that I also need to remove old data to avoid out of memory error or something similar. So, for that reason I added remove entry code, but the graph behaves very strange. Here is my code for adding entires:
LineDataSet set = data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// Add new value
data.addXValue("");
data.addEntry(new Entry((float) value, set.getEntryCount()), 0);
data.setDrawValues(false);
// Remove oldest value
if (data.getXValCount() > VISIBLE_VALUE_RANGE) {
data.removeEntry(0, 0);
data.removeXValue(0);
}
// Let the chart know it's data has changed
lineChartAccelerometer.notifyDataSetChanged();
// Limit the number of visible entries
lineChartAccelerometer.setVisibleXRange(VISIBLE_VALUE_RANGE);
// Move to the latest entry
lineChartAccelerometer.moveViewToX(data.getXValCount() - (VISIBLE_VALUE_RANGE + 1));
The VISIBLE_VALUE_RANGE is 100, and when the value count reaches that, graph starts to disappear from the beginning to the end, and no new value appears. I logcated the entry count, and it seems like everything is fine, after count reaches 100, it stays there, so one value is added and one is remvode.
What am I doing wrong?
Hi!
I'm using the library to dynamicaly display new data in a line chart. I implemented the adding of values based on the RealTimeLineChart example, but I'm worrying that I also need to remove old data to avoid out of memory error or something similar. So, for that reason I added remove entry code, but the graph behaves very strange. Here is my code for adding entires:
The VISIBLE_VALUE_RANGE is 100, and when the value count reaches that, graph starts to disappear from the beginning to the end, and no new value appears. I logcated the entry count, and it seems like everything is fine, after count reaches 100, it stays there, so one value is added and one is remvode.
What am I doing wrong?