Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import PlaygroundSupport
- import Foundation
- import SwiftUI
- import UniformTypeIdentifiers
- import Charts
- struct ToyShape: Identifiable {
- var type: String
- var count: Double
- var id = UUID()
- }
- var data: [ToyShape] = [
- .init(type: "Cube", count: 5),
- .init(type: "Sphere", count: 4),
- .init(type: "Pyramid", count: 4)
- ]
- struct ChartView: View {
- var body: some View {
- Chart {
- BarMark(
- x: .value("Shape Type", data[0].type),
- y: .value("Total Count", data[0].count)
- )
- BarMark(
- x: .value("Shape Type", data[1].type),
- y: .value("Total Count", data[1].count)
- )
- BarMark(
- x: .value("Shape Type", data[2].type),
- y: .value("Total Count", data[2].count)
- )
- }.background(Color.black)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement