Post

Replies

Boosts

Views

Activity

Reply to Swift Chart LineMark create chart each time different
Please make sure the data are sorted. You need to use .sorted(by: { } ) I encounted this problem before, you can see my code for understading. Chart { ForEach(bodydata.sorted(by: { $0.key.toDate2()! > $1.key.toDate2()! }), id:\.key) { key, value in LineMark( x: .value("Week Day", key.toDate2()!, unit: .day), y: .value("HR", value.amount) ) .interpolationMethod(.catmullRom) .symbol() { Rectangle() .frame(width: 8, height: 8) } .symbolSize(30) } }
Oct ’23