Dynamic graph rendering in Android

Akilan picture Akilan · Oct 9, 2010 · Viewed 9k times · Source

I need to draw a graph in Android which continuously gets data from the server. Based on one data item the graph needs to be displayed in various colors. The graph should keep moving from right to left like a ECG graph. Its something like continuous moving graph.

Will I be able to achieve this using Android 2D graphics library? Do I need to use tween animation? Do I have to use interpolators also?

Answer

Nick picture Nick · Feb 22, 2011

This sounds like a two part problem.

Part 1 is figuring out how to get the raw data from the server. Without knowing what sort of server this is, there isnt much to say. If the server does not yet exist, and depending on the frequency and size of the data being sent, you might look at making http requests from the Android client and retrieving either XML or JSON formatted data.

Part 2 is creating and updating the graphical component(s) on the Android. Yes you could do this from scratch using the Android 2D graphics library, but why reinvent the wheel? Take a look at AndroidPlot - http://androidplot.com. AndroidPlot supports dynamic datasources so as soon as you've got your client code in place, you can easily hook that up to an AndroidPlot generated plot widget and redraw it every time you receive an update from the server.