More data

For the second iteration, let's add the data for Amsterdam πŸ”₯ Create a SwiftUI file called : AmsterdamDetailsChart

// Create the data
// and the same BarMark as the previous section

import Charts
import SwiftUI

let amsData: [SalesSummary] = [
    .init(weekday: date(year: 2022, month: 5, day: 2), sales: 22),
    .init(weekday: date(year: 2022, month: 5, day: 3), sales: 43),
    .init(weekday: date(year: 2022, month: 5, day: 4), sales: 30),
    .init(weekday: date(year: 2022, month: 5, day: 5), sales: 75),
    .init(weekday: date(year: 2022, month: 5, day: 6), sales: 34),
    .init(weekday: date(year: 2022, month: 5, day: 7), sales: 68),
    .init(weekday: date(year: 2022, month: 5, day: 8), sales: 142)
]

struct AmsterdamDetailsChart: View {
    var body: some View {
        Chart(parisData) { element in
            BarMark(
                x: .value("Day", element.weekday),
                y: .value("Sales", element.sales)
            )
        }
    }
}

struct AmsterdamDetailsChart_Previews: PreviewProvider {
    static var previews: some View {
        AmsterdamDetailsChart()
    }
}

Last updated