How to modify the bar width in MPAndroidChart BarChart?
As for the latest version of the library BarDataSet does not have this function any longer, its in BarData class.
BarData data = new BarData(dataset);
data.setBarWidth(0.5f);
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.
Kotlin:
barChartView.data = BarData(dataSetList).apply {
barWidth = 0.5f
}
To fit data in graph (No scroll behavior)
barChartView.xAxis.axisMaximum = dataList.size
barChartView.setVisibleXRange(1f,xAxisLabels.size.toFloat())