我在X轴上创建了日期时间格式的折线图。这些值正确绘制,但我想基于1小时间隔显示。现在它直接显示xvalue作为范围。任何人都可以帮忙设置范围吗?
图形图像
let xAxis = self.chartView.xAxis
xAxis.labelFont = .systemFont(ofSize: 10)
xAxis.labelTextColor = .black
xAxis.drawAxisLineEnabled = false
xAxis.valueFormatter = DateValueFormatter()
public class DateValueFormatter: NSObject, IAxisValueFormatter { private let dateFormatter = DateFormatter()
override init() {
super.init()
dateFormatter.dateFormat = "HH:mm" }
public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
return dateFormatter.string(from: Date(timeIntervalSince1970: value)) } }