I'm using the MPAndroidChart library to plot some data from a few sensors. I've found similar questions on SO, but no solutions:
Plot Multiple Charts in one in MPAndroidChart
MPAndroidChart How to represent multiple dataset object with different number of points in the same chart line
The sensors create data at different rates, and each data sample is stored as data structure like this: .
I would like to be able to plot both sensor values on the same chart as two independent traces. However, after attempting to do this using a LineChart (which claims to be able to plot multiple traces on the same graph) I discovered that the MPAndroidChart Library requires that all data be stored as , with the "xIndex" being an index into a single universal (to the traces on the chart) array of X values.
However, this makes plotting data from non-synchronous sources very difficult.
Is there a way, with MPAndroidChart, to create multiple XY traces with independent axis on both the X and Y axis? That is, can I plot something like this:
trace1 = Array of ()
trace2 = another array of ()
trace3...
The only suggestion I saw for a solution was the answer (given by the MPAndroidChart developer) to this question: MPAndroidChart How to represent multiple dataset object with different number of points in the same chart line. However, I'm concerned that using a tag to identify X values will result in slow graphing performance as the dataset grows larger, because I suspect that the library will have to do a lot of string compares and searches to find which Xaxis value corresponds to each Y value.
If it can't be done with MPAndroidChart, can anyone suggest a good library that can do it?
Thanks for any help.
ok, in case anyone else runs into this and needs a suggestion...I've found that Android Plot (http://androidplot.com/) meets my needs. It has good native support for XY graphs and seems like a good package all around.
I wish the javaDocs were a little more developed - a lot of functions have no descriptions, just the function declaration. That's not always enough to go off of. But so far it's working well.
Related
I need to build an app that draws a line graph from data that is sent to the phone over bluetooth in real time. Data that I get should draw a graph similar to this. I tried with MPandroid charts but it's not working because is not supported I checked and GraphView doesn't support unsorted x-axis line graphs either. Does anybody know if SciChart or AnyCharts support?
Yes, the AnyChart Android library supports unsorted xScale and real-time update of the chart. If you need any sample based on AnyChart, please, contact us support#anychart.com
Yes absolutely Scichart supports data not ascending in X.
If you append data to a SciChart Android DataSeries you will see the following warning:
java.lang.UnsupportedOperationException: Data has been changed to a
DataSeries which is unsorted in the X-Direction. Unsorted data can
have severe performance implications in SciChart.
This warning is intended to prevent you from accidentally appending data to a series that is unsorted (which results in poorer performance). If you intended to do this, then simply set DataSeries.setAcceptsUnsortedData(true). Now append away!
There are several axis types in SciChart. In MPAndroidChart you only get a category axis (data is measured in X based on x-index). In SciChart you can get a category axis or a value axis (which measures data based on X-value).
To read more about the different axis types in SciChart, please see this article: Axis Types in SciChart Android
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.
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:
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
I'm currently working on my first android application and now use the achartengine library.
My question: Is there a function to read out y-values from a chart by passing an x-value as a parameter?
I have a line chart using a TimeSeries with several custom dates (for example 07/24/12 and 07/29/12). Now I want to pass another date (for example 07/25/12) and get the corresponding y-value - even though it is not stored in the TimeSeries.
I just wanted to ask, if there is a simple way like a single function to achieve this aim, otherwise I'll think about a more complicated solution on my own. In my above example, of course, it sounds quite easy to calculate the demanded y-value, but in practice it is going to be more difficult I guess.
Thank you.
No, there isn't such thing in AChartEngine.