I'm trying to make a chart with dates on x-axis and consumption per time month/day etc. on y-axis.
I have database of actual states of energy meters in specific datetime:
1.1.2014 - 150 kWh
5.1.2014 - 200 kWh
So I can get consumption/time like - 50/5 => 10 kWh/day for time from 1.1. to 5.1.
I guess I need some resolution, for every day for example (better for every hour), and add the value of consumption in every hour from 1.1. to 5.1.. But then I need to have that resolution on x-axis labels, 1,2,3...31 day of month etc. But I want to achieve that on zoom out I would have another resolution, means another labels on x-axis. Months. Like 1,2,3..12 And values of consumption with lower resolution, rounded in specific months.
I really don't know how to do that, if it's even possible?
I would like to achieve X-axis label in zoom (better for hours in higher zoom):
And X-axis labels for zoomed out, like on this graph:
Do I need to make my map of x-axis labels for whole times (where I have data of consumption) and then fill it with counted values somehow?
PS: I want to achieve this X-axis labels with Bar chart or Cubic line (cube) chart.
Thanks for any tips
Related
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);
I have tried to see if I can do this on AndroidPlot, HelloCharts and MPAndroidChart.
I have a Weight Management App and want to show a chart of how weight has changed over time.
I've just started looking at this and am falling at the first hurdle of plotting irregular intervals on the X axis. All of the examples for all of these seem to show linear plotting with every interval on the X axis having a value plotted.
But my users might weigh themselves everyday for a week and then wait a month before the next weight so there should be a linear date scale and weights mapped against it but with many days not having a value to plot.
Am i missing something obvious or is this something that these libraries just don't do and I will have to look at building it from scratch?
What you could do is simply fill your x-values array with all days up to the current day, beginning from the first day the person weighed himself. (this will support one weight entry per day - if a person weighs himself more often than once a day, you can simply take the e.g. highest value and display it in the chart, and only show the others upon clicking the chart entry)
ArrayList<String> xvals = new ArrayList<String>();
for(int i = startingday; i < currentday; i+= oneday) {
xvals.add(daystring);
}
Each entry in this x-values array will represent one day, in indices from 0 to the last day.
If you want to add the weight measurement for the first day, create a new Entry with x-index 0 and the weight value. If you want to add the weight measurement for the 10th day, add a new Entry with x-index 10 and the weight value.
I'm using AChartEngine in my Android app.
In the line graph the default value of the difference between numbers on
y-axis numbers is always 500 or higher. How can I change this number?
For Example:
the values on the left side start at 500 then 1000 then 1500 and I would like to set the
first number to for example 100, then 200 etc. I can't find a good method in the library.
Kind regards!
Try this in your XYMultipleSeriesRenderer .. It's not enough means increase the value...
renderer.setYLabels(10);
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 want to construct a graph using achartengine library showing some values corresponding to date/time.
The date axis(behaving as X axis) should be present on the top.
Also i want to customize the layout of X axis.
I want to show the date on X axis above and for each date there are certain time intervals.
Example : I want to plot the readings every 4 hours every day . I want to distinguish the readings day wise as well as hour interval wise.
I hope I am clear.
Can somebody please help me in achieving this ?
Thanks !