|
|
@@ -92,7 +92,7 @@ struct MainChartView: View {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private var selectedIOBValue: OrefDetermination? {
|
|
|
+ var selectedIOBValue: OrefDetermination? {
|
|
|
if let selection = selection {
|
|
|
let lowerBound = selection.addingTimeInterval(-120)
|
|
|
let upperBound = selection.addingTimeInterval(120)
|
|
|
@@ -359,40 +359,6 @@ extension MainChartView {
|
|
|
.chartPlotStyle { basalChartPlotStyle($0) }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private var iobChart: some View {
|
|
|
- VStack {
|
|
|
- Chart {
|
|
|
- drawIOB()
|
|
|
-
|
|
|
- if #available(iOS 17, *) {
|
|
|
- if let selectedIOBValue {
|
|
|
- PointMark(
|
|
|
- x: .value("Time", selectedIOBValue.deliverAt ?? now, unit: .minute),
|
|
|
- y: .value("Value", Int(truncating: selectedIOBValue.iob ?? 0))
|
|
|
- )
|
|
|
- .symbolSize(CGSize(width: 15, height: 15))
|
|
|
- .foregroundStyle(Color.darkerBlue.opacity(0.8))
|
|
|
-
|
|
|
- PointMark(
|
|
|
- x: .value("Time", selectedIOBValue.deliverAt ?? now, unit: .minute),
|
|
|
- y: .value("Value", Int(truncating: selectedIOBValue.iob ?? 0))
|
|
|
- )
|
|
|
- .symbolSize(CGSize(width: 6, height: 6))
|
|
|
- .foregroundStyle(Color.primary)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- .frame(minHeight: geo.size.height * 0.12)
|
|
|
- .frame(width: fullWidth(viewWidth: screenSize.width))
|
|
|
- .chartXScale(domain: startMarker ... endMarker)
|
|
|
- .backport.chartXSelection(value: $selection)
|
|
|
- .chartXAxis { basalChartXAxis }
|
|
|
- .chartYAxis { cobChartYAxis }
|
|
|
- .chartYScale(domain: minValueIobChart ... maxValueIobChart)
|
|
|
- .chartYAxis(.hidden)
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// MARK: - Calculations
|
|
|
@@ -472,7 +438,7 @@ extension MainChartView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private func drawIOB() -> some ChartContent {
|
|
|
+ func drawIOB() -> some ChartContent {
|
|
|
ForEach(state.enactedAndNonEnactedDeterminations) { iob in
|
|
|
let rawAmount = iob.iob?.doubleValue ?? 0
|
|
|
let amount: Double = rawAmount > 0 ? rawAmount : rawAmount * 2 // weigh negative iob with factor 2
|