I'm trying to do a chart with rounded corners like the picture below.

I've tried the following code in Path:
.stroke(style: StrokeStyle(lineWidth: 2, lineCap: .round))
and
.stroke(Color.accentColor, style: StrokeStyle(lineWidth: 2, lineJoin: .round))
Nothing seems to work, is this possible? Any option I try in both lines always shows the graph the same way (picture below)
I'm using SwiftUI, swift 5, iOS 15. Thanks in advance.
You can use .interpolationMethod(.cardinal) on your LineMark.
Example:
Chart {
ForEach(data, id: \.id) { item in
LineMark(
x: .value("Day", item.date),
y: .value("Mood", item.value)
).lineStyle(.init(lineWidth: 6))
.interpolationMethod(.cardinal)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With