Can not assign iOS Charts valueFormatter to valueFormatter
I had to update Charts pod because of an xCode update. Now I'm troubling with this funny issue.
let formatter: AxisValueFormatter = XAxisNameFormater(dates: self.formatedDates)
lineChartView.xAxis.valueFormatter = formatter
public class XAxisNameFormater: NSObject, AxisValueFormatter {
var dates:[String] = []
init(dates: [String]) {
self.dates = dates
}
public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
if value < 0 {return ""}
if value == 0.5 {return ""}
if Int(value) >= self.dates.count {return ""}
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "tr&quo开发者_StackOverflow社区t;)
formatter.dateFormat = "dd MMM"
let dateString = formatter.string(from: Date(timeIntervalSince1970: dates[Int(value)].convertToDouble()!))
return dateString
}
}
And the error:
How can this be even possible? Any ideas?
精彩评论