Health Trend Chart

Health Trend Chart

A Health-style resting heart rate card with a smooth line over a gradient area, built with Swift Charts. Drag to scrub: a rule and point snap to each reading with a value bubble and a haptic tick, and the Week, Month and Year switch regrows the line into the new data while the axis relabels.

Luiz Mello
  • chart
  • graph
  • interactive

snippet.swift340 lines

7 files • Scroll to see all →
/// The time window a `HealthTrendChart` shows.public enum HealthTrendRange: String, CaseIterable, Identifiable, Hashable {    case week = "W"    case month = "M"    case year = "Y"​    public var id: String { rawValue }​    var title: String {        switch self {        case .week: "Week"        case .month: "Month"        case .year: "Year"        }    }​    var caption: String {        switch self {        case .week: "Daily average, last 7 days"        case .month: "Daily average, last 30 days"​// ... (click "Show full code" to see more)
Viewing: Model.swift•1 of 7