import SwiftUI // MARK: - Chart height scaling // // Charts declare a base height for compact width. Containers with a wider // canvas (regular width: iPad, iPhone Duo inner screen, Mac windows) raise the // scale so plots gain vertical room instead of just stretching horizontally. extension EnvironmentValues { @Entry var chartHeightScale: CGFloat = 1 } private struct ChartFrameModifier: ViewModifier { @Environment(\.chartHeightScale) private var scale let base: CGFloat func body(content: Content) -> some View { content.frame(height: base * scale) } } extension View { /// Fixed chart height that follows `chartHeightScale` from the environment. func chartFrame(height: CGFloat) -> some View { modifier(ChartFrameModifier(base: height)) } /// Floating label background: Liquid Glass on iOS 26+, material fallback. @ViewBuilder func floatingPillBackground() -> some View { if #available(iOS 26.0, *) { self.glassEffect(.regular, in: .capsule) } else { self .background(.regularMaterial, in: Capsule()) .shadow(color: .black.opacity(0.12), radius: 6, y: 2) } } }