polscm32 před 2 roky
rodič
revize
8ef80b61a2
1 změnil soubory, kde provedl 9 přidání a 1 odebrání
  1. 9 1
      LiveActivity/LiveActivity.swift

+ 9 - 1
LiveActivity/LiveActivity.swift

@@ -214,6 +214,12 @@ struct LiveActivity: Widget {
         if context.isStale {
         if context.isStale {
             Text("No data available")
             Text("No data available")
         } else {
         } else {
+            // determine scale
+            let min = (context.state.chart.min() ?? 40 * (context.state.unit == " mmol/L" ? 0.0555 : 1)) - 20 *
+                (context.state.unit == " mmol/L" ? 0.0555 : 1)
+            let max = (context.state.chart.max() ?? 270 * (context.state.unit == " mmol/L" ? 0.0555 : 1)) + 50 *
+                (context.state.unit == " mmol/L" ? 0.0555 : 1)
+
             Chart {
             Chart {
                 RuleMark(y: .value("high", context.state.highGlucose))
                 RuleMark(y: .value("high", context.state.highGlucose))
                     .lineStyle(.init(lineWidth: 0.5, dash: [5]))
                     .lineStyle(.init(lineWidth: 0.5, dash: [5]))
@@ -240,10 +246,12 @@ struct LiveActivity: Widget {
                 }
                 }
             }
             }
             .chartYAxis {
             .chartYAxis {
-                AxisMarks(position: .leading) { _ in
+                AxisMarks(position: .trailing) { _ in
                     AxisGridLine(stroke: .init(lineWidth: 0.2, dash: [2, 3])).foregroundStyle(Color.white)
                     AxisGridLine(stroke: .init(lineWidth: 0.2, dash: [2, 3])).foregroundStyle(Color.white)
+                    AxisValueLabel().foregroundStyle(Color.white).font(.footnote)
                 }
                 }
             }
             }
+            .chartYScale(domain: min ... max)
             .chartXAxis {
             .chartXAxis {
                 AxisMarks(position: .automatic) { _ in
                 AxisMarks(position: .automatic) { _ in
                     AxisGridLine(stroke: .init(lineWidth: 0.2, dash: [2, 3])).foregroundStyle(Color.white)
                     AxisGridLine(stroke: .init(lineWidth: 0.2, dash: [2, 3])).foregroundStyle(Color.white)