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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With