You can set your xAxis.valueFormatter
to your own custom class and then return now when your x value is 0.
Like:
class ChartValueFormatter: NSObject, IAxisValueFormatter {
func stringForValue(_ value: Double, axis: AxisBase?) -> String {
if value == 0 {
return "Now"
}
let dateFormatter = DateFormatter()
dateFormatter.setLocalizedDateFormatFromTemplate("dd MMM")
dateFormatter.locale = .current
let date = Date(timeIntervalSince1970: value)
return dateFormatter.string(from: date)
}
}
For this to work you need to sort your values based on date and then set then now value timestamp to zero.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…