Straight to the question:
is there any way to set bar entry maximum width? Because when dataset consist of 1 entry, bar consumes all the space and it looks bad.
I have already thought about such a feature. However, the performance overhead for re-calculating over-sized bars is considerable.
As a workaround, for low numbers of bars, you could simply provide a greater amount of x-values. That will automatically make the bars smaller.
I used this:
if (barEntries.size() <=8){ // barEntries is my Entry Array
int factor = 10; // increase this to decrease the bar width. Decrease to increase he bar width
int percent = (factor - barEntries.size())*10;
barDataSet.setBarSpacePercent(percent);
}
barChart.getLayoutParams().height=100*count;
where count is the number of bars to be displayed
@vaiiibhav not working for me
if I have only 1 value, bar height is much more then height in layout params
It's work for me,thx @vcarvalho27
barDataSet.setBarSpacePercent(percent);
replace
BarData.setBarWidth();
And If you only have 1 entry,I think you can set a fixed value,like 0.2f
Most helpful comment
I used this: