Spending Dashboard

Spending Dashboard

A weekly spending summary built with Swift Charts: a donut of categories with the total in the center and a stacked daily bar chart below. Tap or drag a sector and it swells out while the others dim and the headline rolls to that category's amount; pick a day for a rule and a callout.

Luiz Mello
  • chart
  • stat
  • interactive

snippet.swift388 lines

9 files • Scroll to see all →
/// A spending category: name, glyph and chart color.public struct SpendingDashboardCategory: Identifiable, Hashable {    public var id: String { name }    public let name: String    public let systemImage: String    public let color: Color​    public init(name: String, systemImage: String, color: Color) {        self.name = name        self.systemImage = systemImage        self.color = color    }​    public static let samples: [SpendingDashboardCategory] = [        .init(name: "Groceries", systemImage: "cart.fill", color: Color(red: 0.20, green: 0.70, blue: 0.45)),        .init(name: "Dining", systemImage: "fork.knife", color: Color(red: 1.00, green: 0.55, blue: 0.20)),        .init(name: "Transport", systemImage: "tram.fill", color: Color(red: 0.25, green: 0.55, blue: 0.98)),        .init(name: "Shopping", systemImage: "bag.fill", color: Color(red: 0.93, green: 0.33, blue: 0.48)),        .init(name: "Bills", systemImage: "bolt.fill", color: Color(red: 0.98, green: 0.78, blue: 0.20)),    ]​// ... (click "Show full code" to see more)
Viewing: Model.swift•1 of 9