I'm using Swift Charts to create a chart in my app, I want a scrollable view to be able to see chart data over a wide time range, however I am unable to properly get X axis labels to use the picker value (day, month, year)
ScrollView(.horizontal) {
Chart {
ForEach(filteredData) { item in
LineMark(
x: .value("Date", item.day),
y: .value("Measurement", item.value1)
)
.foregroundStyle(Color(measurementType.colour1))
.interpolationMethod(.catmullRom)
.symbol(by: .value("Measurement Type", measurementType.name))
}
}
}
The day values I'm using conform to Calendar.current.date
I tried using this for the line mark where timeUnits was a Calendar.Component selected by the picker
LineMark(
x: .value("Date", item.day, unit: timeUnits),
y: .value("Measurement", item.value1)
)
However, the actual chart values being incorrect then