-
-
Save anupamchugh/6614afca8da86df507a1846624e284a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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