how can i add both time and date on x axis in ios charts by Daniel Gindi?
Thanks in advance for the answers!
extension ChartXAxisFormatter: IAxisValueFormatter {
func stringForValue(_ value: Double, axis: AxisBase?) -> String {
if let dateFormatter = dateFormatter {
let date = Date(timeIntervalSince1970: value)
return dateFormatter.string(from: date)
}
return ""
}}
Configure your dateFormatter with a format string, and add times to that. From memory, something like:
dateFormatter.setDateFormat = "yyyy-MM-dd'T'HH:mm"
Hope that helps!