3

I am building an android real-time accelerometer plotting application using achartengine. I have done a lot of research to solve the problems I mention below but couldn't find any working solutions.

The case is this: I am collecting accelerometer values and filling three XYSeries objects (one per axis). I use the XYSeries objects to plot the graph with the three timeseries. I want the graph to livescroll as the time passes. So I am using a different thread in the activity to update the graph, I am updating the X-axis and then I am calling

view_eeg1.repaint();

where view_eeg1 is of type GraphicalView

However, when I call the repaint method more than 3 or 4 times per second GC_CONCURRENT kicks in. In this thread Dan is discussing a similar issue, but I couldn't make it work smoothly.

Moreover, even if I ignore the GC_CONCURRENT warning messages and try to play with the app, when I move the device a lot, that is the graph becomes really crowded, the application crashes.

So, the main question here is, how to use achartengine for real-time plotting when the sampling and refresh rate become high?

I hope I am describing the problem in adequate detail, please let me know if you need more info.

Community
  • 1
  • 1
dimkots
  • 73
  • 5

1 Answers1

1

Some suggestions that may help:

  • You could repaint only the part of the graph that you know has modified using repaint(left, top, right, bottom) where the parameters define a rectangle on the screen that must repaint.
  • It may help repainting only once every second or so.
  • It may help removing some older values. You definitely don't want several 1000s of values in your series.
Dan D.
  • 32,246
  • 5
  • 63
  • 79
  • Thanks Dan for the answer. 1) As time goes by, the whole graph has to be repainted, especially the X-axis. 2) If I do that, then the `GC_CONCURRENT` problem is solved, but the movement is not smooth at all. 3) I've already removed the older values. Each `XYSeries` only contains the last 1000 accelerometer readings. [This](https://play.google.com/store/apps/details?id=pearson.accelerometer_toy) application runs perfectly and smoothly, I think it uses `achartengine` too. I think that it uses a `HorizontalScrollView` to move the axes, so no pannin in the chart is enabled neither needed. – dimkots Jul 24 '13 at 11:20