Advertisement
dartmeadow

Variable passing final result, File 3

Dec 15th, 2022 (edited)
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.90 KB | Science | 0 0
  1. import PlaygroundSupport
  2. import Foundation
  3. import SwiftUI
  4. import UniformTypeIdentifiers
  5. import Charts
  6.  
  7.  
  8. struct ToyShape: Identifiable {
  9.     var type: String
  10.     var count: Double
  11.     var id = UUID()
  12. }
  13. var data: [ToyShape] = [
  14.     .init(type: "Cube", count: 5),
  15.     .init(type: "Sphere", count: 4),
  16.     .init(type: "Pyramid", count: 4)
  17. ]
  18.  
  19.  
  20. struct ChartView: View {
  21.     var body: some View {
  22.         Chart {
  23.             BarMark(
  24.                 x: .value("Shape Type", data[0].type),
  25.                 y: .value("Total Count", data[0].count)
  26.             )
  27.             BarMark(
  28.                 x: .value("Shape Type", data[1].type),
  29.                 y: .value("Total Count", data[1].count)
  30.             )
  31.             BarMark(
  32.                 x: .value("Shape Type", data[2].type),
  33.                 y: .value("Total Count", data[2].count)
  34.             )
  35.         }.background(Color.black)
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement