MPAndroidChart - animations between real-time data points - android

I am currently using MPAndroidChart to display real-time data. I have been able to add points to a line chart and update a radar chart with the data. However, I am having issues with implementing smooth animations when updating the charts.
So, for example, instead of just redrawing the line chart to include a new point of data, I would like the line to gradually extend to a new data point, sliding to the right if an old data point is being replaced (when outside of the visible axis range). And in the radar chart, if a point of data changes from, say, 20 to 60, I would like the point on the chart to smoothly move from the 20 to 60 instead of the chart being completely redrawn.
At the moment, I have found the animateX, animateY, and animateXY methods in the library. However, these only seem to be for initially creating the chart. I need there to be animations while data is continually added to an existing chart. Is it possible with this library? What kinds of tweaks would I need to make?

Related

MPAndroidChart draw multiple charts lined vertically with shared X axis

I wonder if it is possible to achieve something like this with MPAndroidChart library?
Basically, I want to have multiple line charts with different Y axis stacked vertically sharing the same X axis (when I move, zoom or highlight a value I want them to be synchronized). If I get it right, there is no explicit support for this behavior.
I tried to manipulate the values (set negative ones with offset) of the second dataset and I was able to achieve the desired charts placement. But I couldn't find a way to draw the values correctly on the Y axis (AxisValueFormatter isn't enough because I need alternate granularity).
Now I'm thinking of having multiple charts glued together and synchronized by callbacks and zoom/move/highlight them programmatically. But I fear it may affect the performance since I need to work with thousands of data points.
Any ideas? I may even take a look at other free libraries if they can do it, but I prefer to stick with MPAndroidChart as I have good experience with it.

achartengine - plotting moving and still graphs

Is there any efficient way of doing this? My screenshot from Android device
As for now I am reading accelerometer data
(all graphs are moving to the left edge of screen) and compare them with my black threshold.
When new accelerometer single data arrives, I plot all three values (red,blue,black). This means adding three new points to the correspondent series at the end and removing the first point from series (to enable 'movement').
Is there an option to avoid adding new points to the black graph (threshold) to make it plot in an efficient manner? Or maybe this is quite efficient option, huh?
There are many options to do graphing. If you want static graphing you can use these API's/code samples.
AChartEngine
Simple Line Chart
Draw a Graph
Charts4j
AndroidPlot - one of the best looking ones, does dynamic plots too and is now open sourced.
TeeChart
So many others to choose from but most are static and non of these can handle real time data plots, i.e. ECG wave forms. One example you might want to look at is the Tricorder android example. Problem it is really complex to setup and if you just want the graphs, there is so much code to rip out. It can be done but I even noticed there is a lag the longer you run the program.
So far the only way I have found a real good dynamic graphing, is to do it yourself and use the SurfaceView and then draw usin the path.lineTo() see below for previous SO answer for this solution.
SO example:

How to implement multiple highlight line sliders in line chart

I want to implement single and multiple highlight line sliders in line chart. I am able to get only single highlight line slider with MPAndroidChart (https://github.com/PhilJay/MPAndroidChart) library. But I also need two highlight line sliders to allow the user to select range of values(min and max values) on the chart. Please refer the below image for more information:
Can we achieve the above requirement with any library or we need to draw a custom view?
Any help or guidance will be well appreciated.
In terms of shinobicharts, while the Crosshair could be easily customised to act like one of sliders, in order to have the two sliders you'd probably want to make use of the Annotations feature.
You can create Annotations with custom Views and add them at any X, Y point (in data terms). You can also convert between data values and pixel values via the Axes. It is therefore possible to make the Annotation follow the user's finger as they drag across the screen.
The trickiest part would be placing the circle on the LineSeries at the right Y-value. As I mentioned above you can convert pixel values (e.g. from a user gesture) to data values so you could easily get the X value but the API would leave quite a bit of work up to you in order to get the correct Y value.
This kind of feature is something that is requested quite often and is certainly something we are looking at providing in the future but for now, while possible, it isn't available out-of-the-box.
Disclaimer: I work for shinobicontrols

AChartengine: 1. repaint(), 2. limit data points

1:
I use achartengine to draw a line chart. Since i receive constantly data i want the chart scroll automatically to the right. My Problem is now, that the chart only scrolls when i touch the display of my phone(Android 2.3). Chart is running in extra thread and gets repaint() every ~100 ms.
2: How do i limit the collected data points. Is there an option to save the last 100 points and delete the older values? Currently my app saves all data points and gets slower and slower.
Best regards.
You can dynamically set the visible chart area using: renderer.setXAxisMin() and renderer.setXAxisMax(). Call repaint() after calling these methods.
Using the same APIs as the above you can control which data to be displayed. It's up to you to remove data from the series after that.

Help me optimize this graph animation

I need some help with this simple animation on my Android phone. I'm a newbie with animation and graphics.
I'm graphing accelerometer data as a sliding time series window. As new accelerometer data is read, its data is plotted on the right, pushing previous data to the left, as shown below:
My program is running pretty smoothly, but I would like some help optimizing the animation. Here are my main concerns:
My current implementation reads all the accelerometer data in one thread and keeps the data in a fixed-size FIFO queue to capture the width of the time series window. I then use Timer.scheduleAtFixedRate() to plot out the entire contents of the queue so that the whole graph is re-drawn every 50 milliseconds. Can I improve upon this? Do I really need to re-draw the graph so often like this? In another similar program I've seen, each pixel column is copied to one pixel to the left, rippling down the graph; the newest data's column is drawn on the far-right pixel column. Is this better?
I redraw the legend (in the upper left) in the drawing thread that runs the draw function every 50 milliseconds. Is there any way to "keep" that legend in place instead of having to constantly re-draw it?
Any other help would be appreciated. I have heard of optimizations like double-buffering but am clueless if that would help me.
If the legend and the cross hairs only need to be drawn once, then you should place it into a buffer bitmap. For your graph line maybe try using the Path object to plot the lines. When it gets time to draw the lines just drawLine to the appropriate point and then translate the canvas left appropriately.If

Categories

Resources