I Stucked on my tryings to implement custom labels on xAxis in last update of ios Charts (4.0.3).
Have this code:
// some model inside with parsed JSON, this is working well.
var dataRad = [DataModel]()
var dataEntries = [BarChartDataEntry]()
for item in dataRad {
guard let level = Double(item.level!), let id = Double(item.id!) else { return }
let dataEntry = BarChartDataEntry(x: id, y: level)
// labels.append(item.temp!)
dataEntries.append(dataEntry)
}
// some setup of the Charts, e.g. colors etc.
let xAxis = chartsView.xAxis
xAxis.labelFont = UIFont(name:"Play-Bold", size:10)!
xAxis.labelPosition = .bottom
xAxis.labelCount = self.dataRad.count
xAxis.drawLabelsEnabled = true
let labels: [String] = ["1, 2", "2, 2", "3, 3", "4, 4", "5, 5", "6, 6", "7, 7", "8, 8", "9, 9", "10, 10"]
xAxis.valueFormatter = IndexAxisValueFormatter(values: labels)
This code doesn't work. I can't see labels on my xAxis. But if I delete this formatter, I see defaults values of my "id" var (in "for in" loop).
I've tried some tricks, like extensions, add. class with formatter. Nothing works for me...
Please help to solve this problem with labels. Thank you!