MPAndroidChart - Linechart - shrink part of the graph with no X values - android

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

Related

MPAndroidChart set current visible X axis

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)

How to ensure space between labels MPAndroidChart

I am creating a line chart using MPAndroidChart, all is working great, but I've noticed that at the labels often become bunched up. I know there is a way to prevent this (I've seen other apps that don't have this issue,) but I don't know what setting to enable.
There are a couple of ways you could make the labels fit better.
Decrease the text size of the X axis labels with mChart.getXAxis().setTextSize(float)
Set a label count limit for the X axis using mChart.getXAxis().setLabelCount(int). This should work fine, as you are already not showing one label per data point.
Change the date format of your label.
Some, all or none of these might help you, depending on your requirements. Good luck!

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 time chart set initial range

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);

Android - need a number flip animation

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.

Categories

Resources