I'm trying to make a line chart using MPAndroidChart that has a Y Axis with a min value of 0 and a max of 255, but I haven't been able to get the max value to show up when viewing the chart. It always shows the top value as something like 240 or 250. I've tried a couple variations of setting the label count but that hasn't helped either. Here is what I'm doing right now.
YAxis yAxis = lineChart.getAxisLeft();
yAxis.setAxisMaxValue(255);
yAxis.setAxisMinValue(0);
yAxis.setLabelCount(5);
I'm setting these before I add the data to the chart.
Related
I am using MPAndroidChart to show a bargraph in my Android application. My Y axis values range is in between 0 and 30. I need to show Y axis labels from 0 to 5 always on viewport if Y axis values below 5. If exceeds 5, auto adjust the labels and show as usual. Any way to achieve this.
I use MPAndroidChart to check the graph of the polonomial equation.
I want to get the maximum and minimum values in the graph obtained, but grid line of y axis(left axis) like this.Current Chart
Unlike the above figure, I would like to draw the y grid line of the graph as follows.The chart I want to get
Is there any way to display grid line of max and min value?
I tried to solve it using the setValueFormatter function, but I do not know how to approach it.
https://weeklycoding.com/mpandroidchart-documentation/axis-general/
You can use setShowOnlyMinMax(boolean enabled)
That is used to showing min / max label
I´m using MPAndroidChart 2.0.9 version. I would like to set labels on y-axis from 0 to 100 and display always this range, but i can´t find the chart.setYRange() method.
The range can be customized via the YAxis class.
Here is the documentation: https://github.com/PhilJay/MPAndroidChart/wiki/YAxis-%28YLabels%29
YAxis y = chart.getAxisLeft();
y.setAxisMaxValue(100);
y.setAxisMinValue(0);
You can try to write this:
yAxis.setLabelCount(x)
This code should give you labels in steps of x, assuming you set a min and max value.
Example of my code:
YAxis y = mChart.getAxisLeft();
y.setAxisMaxValue(100);
y.setAxisMinValue(0);
y.setLabelCount(6);
This will give me labels from 0 to 100 in 6 steps, so: 0-20-40-60-80-100.
I using the 2.0.8 release of MPAndroidChart
I have a problem when the y-values are all zero, and the bars are not shown in the BarChart.
I checked the sample project:
Unchanged code:
Just changing for all values of y are zero in the line 260, with
yVals1.add(new BarEntry(0, i));
but this happens:
And the same happens in my project, when some bars have nonzero values, all bars are displayed, like this:
but when all the bars are zero, no bars are shown and only one label is shown on the x-axis
How to fix this?
I need the chart display all values even the values of 'y' are all zero.
i was getting the same kind of problem as you.
i have a bar chart, when all the y values are 0, the bar won't show at all.
but if there is at least one y value that isn't 0, the bar will showed up even the rest of the y values is 0.
so i think this is a bug from MPAndroidChart.
but i found a way to tweak it a little bit.
you need to set the fixed max axis value, when all the y values are 0.
here is the code to set the fixed max axis value :
leftAxis.setAxisMaxValue(100f);
by doing that, when all the y values are 0, you will set max axis value to 100, but you can set it to other value as long as the max axis value is not 0, and the bar chart will shown even if all the y values are 0.
hope it will fix your problem
I am using achartengine 1.0 and I am trying to set the gridlines for my LineChart.
The Y-axis has a min value of 1 and a max value of 7. I need the chart to display every step in this interval, so I added a label for 1, 2,3,... with
addYTextLabel();
Now I would like to display a gridline for every value on the Y-axis.
But when I add the grid for this axis, there are only 3 lins, at 2, 4 and 6.
How can I get the grid to show a line for all values?
best regards,
htz
with setYLabels() you can set the number of displayed labels for the Y axis. With a displayed label, there comes a gridline.