In the following image there is a space between the xAxis of the chart and the bottom of the bars, the area in red.
I want to know how to remove such space so the labels get closer to the bars. Here is my code:
let chart = BarChartView()
chart.leftAxis.drawGridLinesEnabled = true
chart.leftAxis.drawAxisLineEnabled = false
chart.leftAxis.axisLineColor = .paleBlue
chart.rightAxis.drawGridLinesEnabled = false
chart.rightAxis.drawAxisLineEnabled = false
chart.rightAxis.drawLabelsEnabled = false
chart.xAxis.drawGridLinesEnabled = false
chart.xAxis.labelPosition = .bottom
chart.xAxis.centerAxisLabelsEnabled = true
chart.xAxis.granularityEnabled = true
chart.xAxis.enabled = true
chart.legend.enabled = true
chart.legend.horizontalAlignment = .center
chart.doubleTapToZoomEnabled = false
chart.pinchZoomEnabled = false
chart.noDataText = ""
To solve my problem I found out that I had to remove the xAxis line, the line inside the red rectangle.
I did it by changing attribute xAxis.drawAxisLineEnabled to false. Then I got a whitespace area here painted in red.
To remove this space I changed attribute xAxis.yOffset to -10, this brought the xAxis labels closer to the chart.
I had to change xAxis.drawAxisLineEnabled to false because this line is not affected by xAxis.yOffset, if I did not set it to false the result would be this.