
import SwiftUI
import Charts
struct Items : Identifiable {
var id = UUID()
let type : String
let value : Double
}
struct ContentView: View {
let items : [Items] = [
Items(type: "Medical", value: 10000),
Items(type: "Engeneering", value: 5000),
Items(type: "singing", value: 15000),
Items(type: "pilot", value: 1000),
Items(type: "athlete", value: 18000),
]
var body: some View {
NavigationView{
ScrollView{
Chart(items){item in
BarMark( x: .value("Job", item.type),
y: .value("salary", item.value)
)
.foregroundStyle(.brown)
.cornerRadius(10)
}
.frame(height: 200)
.padding()
}
.navigationTitle("Charts")
}
}
Подробнее здесь: https://stackoverflow.com/questions/766 ... ar-chart-u