Im seeing "Charts: Falling back to a fixed dimension size for a mark. Consider adding unit to the data or specifying an exact dimension size." while using charts on SwiftUI. Does anyone knows what this error is talking about? I couldn't find it online.
Chart {
ForEach(data) { dataPoint in
BarMark(x: .value("Day", dataPoint.day, unit: .day),
y: .value("Minutes", dataPoint.number))
}
}
.chartXAxis {
AxisMarks(preset: .aligned){ _ in
AxisValueLabel()
}
}
.chartYAxis {
AxisMarks(preset: .automatic){ _ in
AxisValueLabel()
AxisGridLine()
}
}
Ok after more research I found what was missing about the "fixed dimension size for a mark" It gives a fixed size for each bar as the error says and it's done like:
The "width: 8" part. And it looks like:
The "adding unit to the data". It should be a Date unit and you have to be working with that type on your Data. It gives an automatic width depending on how much data do you have. Is done like this:
And looks something like this: