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);
Related
Using MPAndroidChart, I'm struggling to figure out how to set the current visible x axis values. The use case is simple and I would have thought very common, so I'm sure I must be missing some function which can do this:
Say you have a chart with x axis values 1-100
A user zooms and pans a chart so that the range 60-80 is visible. I want to store these values, so that tomorrow when the user re-launches the app, I can restore the exact viewing state (60-80)
Storing the values is really easy - you can simply call chart.lowestVisibleX and chart.highestVisibleX to get the x axis values. But how do I set them on a new instance of the chart? Unfortunately there doesn't seem to be a chart.setHighestVisibleX or chart.setLowestVisibleX.
This previous question / answer is nearly, but not quite, what I need. The suggestion is to use a combination of chart.moveViewToX(60) and chart.setVisibleXRangeMaximum(20). However as the docs for setVisibleXRangeMaximum state:
Sets the size of the area (range on the x-axis) that should be maximum
visible at once (no further zooming out allowed)
I don't want to prevent further zooming, which is what this does. There must be a way to set the zoom level without actually restricting further zooming - but I can't figure it out. Any suggestions?
Thanks
Just to answer my own question, I decided to workaround this issue by resetting the X range maximum after calling moveViewToX. This appears to work. So the solution would be:
chart.setVisibleXRangeMaximum(20)
chart.moveViewToX(60)
chart.setVisibleXRangeMaximum(100)
Is it possible to do something like this:
? I have in the app LineChart with the time values (seconds) on X axis and temperature on Y axis.
And it's possible that I don't have a data for some bigger time interval (day and more for example) and it will not be very user frinedly if user has to swipe so much back. So I want to create this "shortcut" or somehow "delete" empty part of the graph (with no X values). Is is possible? Maybe there don't have to be this gap but I need to contine from time "10:30" to time "14:20" in one graph without big scrolling.
Do you have some suggestions?
Have a look at this and
this
There is a way to get a continued graph and don't have an empty gap in between however the way you are looking for kind of seems like a drag because even though you explicitly dont add the empty data to dataset, it is meant to work like a continued thing.
Hope this helps, cheers
I've been working with Androidplot library for generating line plots and be able to do zoom and pan, so I'm using a modified version of XYPlotZoomPan class.
My current chart is showing some values per day, in a range of dates, so if I'm showing 7 days the domain axis is readable but if I'm trying to show 30 days it turns into a mess.
My goal is to show 7 days and have the option of scrolling through the rest of the chart that is not shown.
The only function that handles boundaries is setDomainBoundaries, currently I've tried this:
setDomainBoundaries(min, max, BoundaryMode.FIXED);
But it lets me show values inside this range and I'm loosing the ability for panning through the rest of the days.
Does someone have an a idea how I can do that? Thanks.
You can create your own domain value format with myplot.setDomainValueFormat(Format f). From here you can create your own formatter.
Another option you can look at is setDomainStep, a good example of that can be found here
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.
I'm developing an Android application to read "electric meters". The user enters the counter - the application calculates the consumption and sends it to a server.
The representation of the counter should look like a old electricity meters
old electricity meter
I've already integrated the counter-numbers as images. I will have an animation that if the user enters a number (keyboard) then the relevant section begins to rotate to the correct number position.
For example: The user enters the number 5 for the first digit, then rotate the digit from 0-5. The animated numbers flip to the correct position. How can I do this? Any idea?
thank u!!!
There is a custom view which I've created for a custom application. Initially, i also tried searching for this type of view but couldn't found any. So created one of my own.
You can see the code here: https://github.com/Vinayrraj/Android-FlipDigitView
Also this video might help you: http://youtu.be/d6-M2nN2Gzg
You can take a look to Ticker, an Android text view with scrolling text change animation:
Ticker is a simple Android UI component for displaying scrolling text.
Think about how an odometer scrolls when going from one number to the
next, that is similar to what Ticker does. The Ticker handles smooth
animations between strings and also string resizing (e.g. animate from
"9999" to "10000").
I'd have one spinning animation - but make it fast and blurred so you can't see what number it's on - play that for 1 second, then replace with the correct position - it's a trick, but will save you doing lots of different animations.
If I got your need, I would use two different approach:
1) one big animation with numbers from 0 to 9; when you have an inoput number, you should launch the animation and stop at the right frame (just a math calculation matter);
2) one animation for each number; you could think about a number flipping as if its rotating on itself vertically; then, when the user put his number X, you have to flip between X different animations until the good one and stop.