How to modify the bar width in MPAndroidChart BarChart?

Rakesh picture Rakesh · Mar 24, 2015 · Viewed 23.5k times · Source

I am using MPAndroidChart library.

I would like modify the size of bar present in bar chart. Could you let us know where to check for modify size of bar in bar chart in mp android chart

Answer

abhi picture abhi · Aug 5, 2015

You can reduce the spacing between the bars that will automatically increase the width of bars.

BarDataSet set = new BarDataSet(vals, "Set A");
set.setBarSpacePercent(50f);

UPDATE v3.0.0:

As of this library version, you can control the bar width with the following method:

BarData barData = new BarData(...);
barData.setBarWidth(1f);

The number you provide for this method represents a certain interval on the x-axis. If your total axis has a range of e.g. 10k, and you set the bar width to 1000, the bar will cover 10% of the total x-axis range.