Dynamic graph rendering in Android

时间秒杀一切 提交于 2019-12-05 00:43:35

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3896905/dynamic-graph-rendering-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!