I recently update the MPAndroidChart library from 1.7.4 to 2.0.9 and I forgot what I did to customize the linechart to make the data displaying from right to left. Does anyone know? I am wondering if there is a method to call to do that.
There is no method. But it can still be done because it only depends on how you add the data.
Just add values at higher x-indices first.
Say you got a chart with x-axis labels from January to December with an x-axis range from 0 - 11 (12 values).
Now add the december value at index 11, and so on.
If you want to set the first data point other than zero and have the data display in left to right manner use moveViewToX(float xValue).
moveViewToX(float xValue): Moves the left side (edge) of the current viewport to the specified xValue.
Related
I'm using MPAndroid chart to display a line chart.
The chart is updated with different data and of course, when the data changes, the y-axis lines and the zoom level is changed because of the different sets of input data.
Is there any way to maintain the position of the y-axis lines and only change their labels according to the new data?
Thanks!
After a lot of tries and investigations, it seems that I found a solution just after posting the question.
Just in case someone else needs this, I used the setLabelCount function before but never the one with the force parameter.
The solution is:
mChart.getAxisLeft().setLabelCount(visibleYCount, true);
Forcing the label count will assure the number of y-axis lines and thus, their position is stable with different data sets.
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 am working with the MPAndroidChart library and I am trying to produce a Horizontal Bar Chart with only one item in the data set. The issue I am running into is setting the max value for the x-axis. I would like to say the max X value is 1000 and if the value in the data set is 500 then the bar chart would only go 1/2 way across the screen. My issue is that I can't seem to find a way to set the max value of the x axis for the Horizontal Bar Chart in the MPAndroidChart library.
I know this is kind of misleading, but for the HorizontalBarChart, this needs to be set via the y-axis :-)
Here is the full documentation of the YAxis.
Check out the setAxisMaxValue(float max) method.
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
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);