Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Last active June 8, 2022 05:23
Show Gist options
  • Save anupamchugh/6614afca8da86df507a1846624e284a3 to your computer and use it in GitHub Desktop.
Save anupamchugh/6614afca8da86df507a1846624e284a3 to your computer and use it in GitHub Desktop.
import SwiftUI
import Charts
struct ContentView: View {
var chartValues : [ChartValues] =
[
.init(name: "A", value: 50, color: .green),
.init(name: "B", value: 100, color: .blue),
.init(name: "C", value: 120, color: .orange),
.init(name: "D", value: 150, color: .yellow),
.init(name: "E", value: 200, color: .red)
]
var body: some View {
Chart {
ForEach(chartValues){
(chart) in
BarMark(x: .value("S", chart.name), y: .value("S",chart.value))
.foregroundStyle(chart.color)
}
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment