dimkots
dimkots

Reputation: 73

Android Real-Time Plotting

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.

Upvotes: 3

Views: 1068

Answers (1)

Dan D.
Dan D.

Reputation: 32391

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.

Upvotes: 1

Related Questions