MPAndroid Chart GroupedBarChart center x-axis and ignore entries - android

I'm making a GroupedBarChart which will have three bars. The following image is a case where only 1 bar has a value.
How can I make the x-axis values line up in the middle of grouping? It seems almost centered at first and you can see it moves to the right. It gets worse as I add values.
Also, is there a way to ignore entries that have a value of 0?

Related

MpChart Combined chart auto scroll option

I am using MP chart lib for my android project. I am creating CombinedChart(Bar chart & Line chart) with negative values. Charts is coming up, But when I increase the number of values across X axis, bar width decreases in order to accommodate the values.
screen shot
How can I include values along X axis without shrinking the bar width and when graph comes up user can scroll horizontally to see all the values.
I am setting
Try this it will work :
combinedChart.setMaxVisibleValueCount(10);
give your number instead of ten

How to set maximum x-axis value for HorizontalBarChart?

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.

Issues faced while drawing dynamic line graph using AChartEngine in Android

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

Negative Barchart with Androidplot

I'm using the Androidplot library to plot a Barchart to display something.
The range of my values are -40 till +40.
How can I plot a bar to the negative side? I just want to center the zero on the y-axis in the middle and the bars should growing up or down, if the value is positiv of negativ. My bars are growing from the lower bound upwards. It should look like this:
That works for me:
plot.centerOnRangeOrigin(0);
plot.setRangeLowerBoundary(0,BoundaryMode.AUTO);
Where plot is a instance of XYPlot.
Negative bar support has recently been added to Androidplot 0.6.2; you'll need to use the latest development version to get it (it's very stable).
Once you have the correct version of Androidplot you can use Maria Reina's suggestion to enable the display of negative values. Here's how I'm doing it in the screenshot below:
plot.setUserRangeOrigin(0);
plot.setRangeBoundaries(0, BoundaryMode.AUTO, 0,BoundaryMode.AUTO);
Note : There is currently a bug where if you are using overlay mode with 2 or more series and have negative bars, the overlay order of negative bars is reversed, causing the smaller negative values in a bargroup to be obscured by the larger ones. If your goal is simply to reproduce the image above though then you should be fine.
That's a great question. I think there's no way to do that with the current version of AndroidPlot (0.6.0) with a single series of values.
I created a workaround in my project. I know it's not perfect, but it works: create two series that overlap, one in green and one in the background color. Suppose you have your currentValue to draw..
if (currentValue>=0) {
greenRes[i] = Float.valueOf(currentValue);
coverRes[i] = Float.valueOf(0);
}
else {
greenRes[i] = Float.valueOf(0);
coverRes[i] = Float.valueOf(currentValue);
}
In this way you always have the green bar starting from the zero axis and going up or down.

Intersection of GridLines and line chart y-axis value

I am able to display the AChartEngine's TimeChartView to user, but when the graph renders, the grid lines (vertical - set by showGridLines(true)) and the line drawn on graph to display corresponding y-axis value (time in secs) against the dates on x-axis don't intersect with each other.
The y-axis value pt shows up either before the x-axis value or after it, but not exactly on it.
Please suggest, if there's any achartengine property which needs to be set to get this done / any other thing that needs to be done for getting this done.
Thanks
Omkar Ghaisas
Sample Image --
As can be seen, the points marked with ovals don't coincide with the vertical grid lines and with x axis values, but start before that. E.g the first y value for 7200 should start at vertical line of 02/03/2012, but instead starts before that. Similarly for all other data points.
This was fixed in the AChartEngine SVN.
Please see this for extra information.

Categories

Resources