Bar Mark
Swift Charts calls visual elements "marks"
// We add a tabBar
// then we build a `BarMark` with 2 elements
import Charts
import SwiftUI
struct ContentView: View {
@State private var selection = 2
var body: some View {
TabView(selection: $selection) {
WinesTab()
.tabItem {
Label("Wines", systemImage: "chart.bar.doc.horizontal")
}
.tag(1)
}
}
}
struct WinesTab: View {
var body: some View {
Chart {
BarMark (
x: .value("Name", "Margaux"),
y: .value("Sales", 900)
)
BarMark(
x: .value("Name", "Médoc"),
y: .value("Sales", 460)
)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Last updated