AChartEngine does not display the maximum chart value - Bar Chart - android

I am working on Achart Engine and i am facing 2 issues
Issue
1) i am facing exactly same problem as posted in the screen shot here displaying max chart values on Y axis
2) suppose in the 3 bars if i one among the bar is 0 say middle one then the bar will not be drawn and shows blank between the two bars, but i dont want to show some space.
On Issues what i want to acheive:
Issue 1) My Ymax value is 50 ,i can make the Y max value to 60 so that the max value is displayed and will not cut.But what happens is now its display 10,20,30,40,50 in Y axis but if i make it 60 it displays 20,40,60 but i want it to display 10,20,30,40,50,60.
Issue 2) If the middle bar value is 0 or any other bar value which is draw is 0 then i dont want to show a space there or dont draw the bar at all.
Please help me to acheive this.
EDIT:
SCREEN SHOT :
I cannot post a screen shot here lack of reputation so i am posting it here please see to it
IMAGE

Just set the Y axis maximum value to something that is higher than the biggest value.
Bar charts with value of zero must be displayed. If there isn't any value to be added than just use MathHelper.NULL_VALUE.

There are two ways to solve this problem.
One of the ways is to set the margin color to transparent in the renderer
renderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
This solution works unless your series have values that are outside the range of the chart. You can either recreate your series so all values are inside the range, or go for solution 2.
Solution 2 is to multiply the max Y value of your chart by 1.1, and set it as the Y max
mRenderer.setYAxisMax(maxvalue*1.1);

Related

Android MP Chart lib scroll bar indicator on X and Y axis

com.github.mikephil.charting.charts.LineChart
not able to add the scroll bar on x and y-axis
can anyone help me out?
setVisibleXRangeMaximum(float maxXRange): Sets the size of the area (range on the x-axis) that should be maximum visible at once. If this is e.g. set to 10, no more than 10 values on the x-axis can be viewed at once without scrolling.
setVisibleXRangeMinimum(float minXRange): Sets the size of the area (range on the x-axis) that should be minimum visible at once. If this is e.g. set to 10, it is not possible to zoom in further than 10 values on the x-axis.
setVisibleYRangeMaximum(float maxYRange, AxisDependency axis): Sets the size of the area (range on the y-axis) that should be maximum visible at once. You also need to provide the axis this constraint should apply to.
After that u will get scrolling in your chart on both of the axis. Question is not very clear but I think you are looking for that by fixing number of entries on a view and by scrolling user can see other values present in chart. If that is the case then use above methods. Hope It helps :) Happy Coding :). Do let me know if it works or if your requirement is different please do elaborate.

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.

AChartEngine: "Auto-scaling" a chart with multiple Y-axes

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.

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

Categories

Resources