show full week in charts even when days are empty

Hi,

im building a swiftui chart for showing hours per day. it works fine. but I want to display a whole week even if there is no data on several days. it is based on core data.

does anyone know how to modify x axis to show always the full week?

thx Chris

Chart
                {
                    ForEach(zeiten, id: \.self.startdatum?.weekDay)
                    {
                        zeit in
                        BarMark(
                            x: .value("day", zeit.startdatum ?? Date(), unit: .day),
                            yStart: .value("Low", zeit.startzeit?.timeDouble ?? 0),
                            yEnd: .value("High", zeit.endzeit?.timeDouble ?? 0))
                    }
                    .cornerRadius(8)
                    .foregroundStyle(.userGreen)
                }
                .frame(width: geometry.size.width*0.75, height: 90)
                .padding()
                .chartYScale(domain: 0...24)
                .chartXAxis {
                    AxisMarks(values: .stride(by: .day, count: 1)) { _ in
                            AxisValueLabel(format: .dateTime.weekday(.narrow))
                            AxisGridLine()
                            AxisTick()
                    }
                }

Not sure if you figured this out or not, but I used something like this

.chartXScale(weekStartDate...weekEndDate)

Just provide the Date properties for weekStartDate and weekEndDate for which dates you want it to start and end.

show full week in charts even when days are empty
 
 
Q