开发者

Can not assign iOS Charts valueFormatter to valueFormatter

开发者 https://www.devze.com 2022-12-07 19:01 出处:网络
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)

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:

Can not assign iOS Charts valueFormatter to valueFormatter

How can this be even possible? Any ideas?

0

精彩评论

暂无评论...
验证码 换一张
取 消