struct Workout: Identifiable { let id = UUID() let day: String let minutes: Int }extension Workout { static let walkWorkout: [Workout] = [ .init(day: "Mon", minutes: 23), .init(day: "Tue", minutes: 35), .init(day: "Wed", minutes: 55), .init(day: "Thu", minutes: 30), .init(day: "Fri", minutes: 15), .init(day: "Sat", minutes: 65), .init(day: "Sun", minutes: 81), ] }
import Charts import SwiftUIstruct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) } } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) } .foregroundStyle(.orange.gradient) } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .lineStyle(.init(lineWidth: 10)) } .foregroundStyle(.orange.gradient) } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .lineStyle(.init(lineWidth: 10, dash: [1,3,5])) } .foregroundStyle(.orange.gradient) } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .lineStyle(.init(lineWidth: 10, lineCap: .round)) } .foregroundStyle(.orange.gradient) } } .padding() } }
.lineStyle(.init(lineWidth: 10, lineCap: .round, lineJoin: .round))
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .lineStyle(.init(lineWidth: 10, lineCap: .round, lineJoin: .round)) } .foregroundStyle(Gradient(colors: [.yellow, .orange, .pink])) } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .lineStyle(.init(lineWidth: 10, lineCap: .round, lineJoin: .round)) } .foregroundStyle(Gradient(colors: [.yellow, .orange, .pink])) .interpolationMethod(.cardinal) } } .padding() } }
.interpolationMethod(.cardinal)
.interpolationMethod(.catmullRom)
.interpolationMethod(.linear)
.interpolationMethod(.monotone)
.interpolationMethod(.stepCenter)
.interpolationMethod(.stepEnd)
.interpolationMethod(.stepStart)
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .annotation(position: .leading) { Text("🚶") } } .foregroundStyle(Gradient(colors: [.yellow, .orange, .pink])) .interpolationMethod(.catmullRom) } } .padding() } }
struct ContentView: View { @State private var walk = Workout.walkWorkout var body: some View { VStack { Text("DevTechie.com") .font(.largeTitle) .foregroundColor(.primary) Chart { ForEach(walk) { w in LineMark(x: .value("Day", w.day), y: .value("Mins", w.minutes)) .annotation(position: .leading) { Text("🚶") } } .foregroundStyle(Gradient(colors: [.yellow, .orange, .pink])) .interpolationMethod(.catmullRom) .symbol(Circle()) } } .padding() } }
With that we have reached the end of this article. Thank you once again for reading. Subscribe our newsletter at https://www.devtechie.com