Sergey Gamayunov Sergey Gamayunov - 1 year ago 100
Swift Question

Horizontal bar chart doesn't start at 0

Sample Chart

When I provide data for Bar Chart it appears with little offset. I thought about stacked Bar Chart, but it was wrong - that how I provide sample data for chart:

var barEntries = [BarChartDataEntry]()
barEntries.append(BarChartDataEntry(x: 0, y: 0))
barEntries.append(BarChartDataEntry(x: 4, y: 1))
barEntries.append(BarChartDataEntry(x: 8, y: 24))
barEntries.append(BarChartDataEntry(x: 12, y: 37))
barEntries.append(BarChartDataEntry(x: 16, y: 27))
barEntries.append(BarChartDataEntry(x: 20, y: 11))

let barDataSet = BarChartDataSet(values: barEntries, label: nil)
let barData = BarChartData(dataSet: barDataSet)
barData.barWidth = 4 = barData

was created with
initializers for non-stacked bar. Now I have no idea why bar doesn't start at 0.

Answer Source

try set yAxis.axisMinimum = 0. Check ChartsDemo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download