Include example how to access time stamp and value #61
Open
Description
It would be great if you could add an example on how to access time stamp and values most effectively.
I came up with the following setup
var dataPoints = [DataPoint]()
do {
try records?.forEach {
if let time = $0.values["_time"] as? Date, let values = $0.values["_value"] as? Double {
dataPoints.append(DataPoint(date: time, value: values))
}
}
} catch {
print (error)
}
to fill DataPoint to be used in SwiftUI Charts.
struct DataPoint: Identifiable {
var date: Date
var value: Double
var id = UUID()
}
Maybe this could be done more elegantly. It would great to have your thoughts.
Metadata
Assignees
Labels
No labels