I'm using AChartEngine's TimeSeries to display four separate series of values. The "values" have vastly varying scales - one of them is a fraction (varies between 0 and 1), the other has a range of 0 to 1000.
Now, I want to display all four of them simultaneously. I have been able to do this, but the problem is the line for the fraction is always hugging the X-axis since the variation between 0 and 1 is indistinguishable when the Y axis is from 0 to 1000.
One solution I though of was that I'd convert all the values to a common scale before adding them to the series. That way, all the four lines are always on the same scale. I can get rid of the Y-axes altogether. Cool.
But this presents another problem: I also allow the user to select individual series to view; and this time, I want to
Display the individual Y-axis
Display the un-scaled values.
But, since I added scaled values, the chart has now lost the original values and will only display the scaled value.
So, my question is: Is there a way to scale the values on the Y-axes when multiple series are being charted, and to revert to the un-scaled values when the single series is shown?
Also, how do I hide only the Y-axes while still displaying the X-axis?
You can use the multiple scale charting in AChartEngine. The chart type is CombinedXYChart. You can see an example here.
Another thread explaining this approach is this.
Related
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.
I am making an app which retrieves data from a database and shows it on a barchart. I have defined a limit line using the provided methods at 30f (on the Y axis).
The problem is, that I want that limit line to be always shown and it only becomes visible when one of the Graph's Bars raises above that value (30f).
Is there a way to always show it?
I have tried with the zoom functions with no luck.
Modify the YAxis display range to your needs: https://github.com/PhilJay/MPAndroidChart/wiki/YAxis-(YLabels)
Especially those methods should help:
setAxisMaxValue(float max): Set a custom maximum value for this axis. If set, this value will not be calculated automatically depending on the provided data.
setAxisMinValue(float min): Set a custom minimum value for this axis. If set, this value will not be calculated automatically depending on the provided data.
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
SOLUTION
Instead of using setInitialRange() I had to set the initial x-values using setXAxisMin() as well as setXAxisMax(). A little bit confusing, I think.
ORIGINAL QUESTION
I'm currently working on a project involving the acharteninge library for drawing time diagrams which works excellent so far. The user is capable of switching between various graphs (one XYMultipleSeriesDataset plus one TimeSeries per graph) via separate buttons. So far, achartengine displays all x values when the graph is shown.
However, I was asked to display only the data captured in the first three hours when the graph is shown, as this information is most relevant. Nevertheless, the user should still be able to scroll to data captured after the first three hours meaning that limiting the x-axis maximum value is not an option.
For example: There are two curves. The first curve is drawn using data captured over a period of 4 hours, while the second curve is created out of data captured over 18 hours.
In the current version my programme initially displays all data of the graph which gets displayed meaning the first curve shows three hours of very relevant data while 1 hour of not so important information is shown too. The "ratio" of the second curve is 3 to 15 (highly significant data vs regular data). As a result, a different amount of high important information is shown when the user compares the two curves making it harder for the user to compare this data, as he has to adjust the zoom manually.
EDIT 01.04.2015 15:46
For setting the initial range I use the XYMultipleSeriesRenderer instance's method setInitialRange(double[] initialRange); which does not affect the graph at all. Below you can see my statement (currentlyProcessedCurve.getRecordStart() is an instance of Joda's DateTime and furhtermore it's the x value of the first displayed point):
public static final int CHART_X_AXIS_INITIAL_MAX = 3;
public static final int CHART_MARGIN_PAN = 45;
...
double[] initialRange = { currentlyProcessedCurve.getRecordStart().minusMinutes(ApplicationSettings.CHART_MARGIN_PAN).toDate().getTime(), currentlyProcessedCurve.getRecordStart().plusHours(ApplicationSettings.CHART_X_AXIS_INITIAL_MAX).toDate().getTime(), 0, 600 };
currentDatasetRenderer.setInitialRange(initialRange);
TIDE (Edit end)
The screenshot below approximately shows how the curve should look initially (Just for making it clear: Please only consider the graphs' shapes, as they should look equal --> What I'm trying to say: I know that the x-axis and the y-axis label of the two screenshots different, but I don't have better pictures yet):
desired initial range
Finally, the following screenshot shows how the curve looks when displayed:
For enabling the user to compare the curves I have locked the y-axis zoom.
Any help is highly appreciated. Thanks in advance!
Have you consider pan option?
With this option you can limit axis maximum, and your chart will show the important data on start, while user can scroll left or right (wherever you have less important data points).
All you need to do is:
set pan enabled for axis you need
set pan limits (so user can't scroll past the last data point)
Hope this helps,
Cheers.
Instead of using XYMultipleSeriesRendererInstance.setInitialRange() I had to set the initial x-values using XYMultipleSeriesRendererInstance.setXAxisMin() as well as XYMultipleSeriesRendererInstance.setXAxisMax().
double xMinValue = ...;
double xMaxValue = ...;
currentDatasetRenderer.setXAxisMin(xMinValue);
currentDatasetRenderer.setXAxisMax(xMaxValue);
How to stop scrolling of AChartEngine dynamic line graph along the y-axis?
When I dynamically plot values I wish to display the recent plotted value. How to do that?
I wish to plot y- axis values in range 20 to 200 and want to display only 5 values so I have used mRenderer.setYLabels(5); But, when I do so grid lines are displayed for only those values. And user will not be able to know the exact y axis co-ordinate. How to show grid lines for each value and show labels for only some values?
If I manually scroll graph horizontally towards right or left, x-axis labels change. I set range as 0-10 with setXLables(2); but it changes to 0,5,10… How to control this behavior?
These should be 4 separate questions, not numbered ones. So, I will only answer the first one of them:
You can set the min and max displayed values:
renderer.setXAxisMin(minValue);
renderer.setXAxisMax(maxValue);
If by scrolling you mean panning, then this is the way to do:
renderer.setPanEnabled(false, false);
renderer.setZoomEnabled(false, false);