|
@@ -49,9 +49,9 @@ struct BasalProfileStepView: View {
|
|
|
.font(.headline)
|
|
.font(.headline)
|
|
|
.padding(.horizontal)
|
|
.padding(.horizontal)
|
|
|
|
|
|
|
|
-// basalProfileChart
|
|
|
|
|
-// .frame(height: 180)
|
|
|
|
|
-// .padding(.horizontal)
|
|
|
|
|
|
|
+ basalProfileChart
|
|
|
|
|
+ .frame(height: 180)
|
|
|
|
|
+ .padding(.horizontal)
|
|
|
}
|
|
}
|
|
|
.padding(.vertical, 5)
|
|
.padding(.vertical, 5)
|
|
|
.background(Color.purple.opacity(0.05))
|
|
.background(Color.purple.opacity(0.05))
|
|
@@ -332,61 +332,61 @@ struct BasalProfileStepView: View {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Chart for visualizing basal profile
|
|
// Chart for visualizing basal profile
|
|
|
-// private var basalProfileChart: some View {
|
|
|
|
|
-// Chart {
|
|
|
|
|
-// ForEach(Array(onboardingData.basalProfileItems.enumerated()), id: \.element.id) { index, item in
|
|
|
|
|
-// let displayValue = onboardingData.basalProfileRateValues[item.rateIndex]
|
|
|
|
|
-//
|
|
|
|
|
-// let tzOffset = TimeZone.current.secondsFromGMT() * -1
|
|
|
|
|
-// let startDate = Date(timeIntervalSinceReferenceDate: onboardingData.basalProfileTimeValues[item.timeIndex])
|
|
|
|
|
-// .addingTimeInterval(TimeInterval(tzOffset))
|
|
|
|
|
-// let endDate = onboardingData.basalProfileItems.count > index + 1 ?
|
|
|
|
|
-// Date(
|
|
|
|
|
-// timeIntervalSinceReferenceDate: onboardingData
|
|
|
|
|
-// .basalProfileTimeValues[onboardingData.basalProfileItems[index + 1].timeIndex]
|
|
|
|
|
-// )
|
|
|
|
|
-// .addingTimeInterval(TimeInterval(tzOffset)) :
|
|
|
|
|
-// Date(timeIntervalSinceReferenceDate: onboardingData.basalProfileTimeValues.last!).addingTimeInterval(30 * 60)
|
|
|
|
|
-// .addingTimeInterval(TimeInterval(tzOffset))
|
|
|
|
|
-//
|
|
|
|
|
-// RectangleMark(
|
|
|
|
|
-// xStart: .value("start", startDate),
|
|
|
|
|
-// xEnd: .value("end", endDate),
|
|
|
|
|
-// yStart: .value("rate-start", displayValue),
|
|
|
|
|
-// yEnd: .value("rate-end", 0)
|
|
|
|
|
-// ).foregroundStyle(
|
|
|
|
|
-// .linearGradient(
|
|
|
|
|
-// colors: [
|
|
|
|
|
-// Color.purple.opacity(0.6),
|
|
|
|
|
-// Color.purple.opacity(0.1)
|
|
|
|
|
-// ],
|
|
|
|
|
-// startPoint: .bottom,
|
|
|
|
|
-// endPoint: .top
|
|
|
|
|
-// )
|
|
|
|
|
-// ).alignsMarkStylesWithPlotArea()
|
|
|
|
|
-//
|
|
|
|
|
-// LineMark(x: .value("End Date", startDate), y: .value("Ratio", displayValue))
|
|
|
|
|
-// .lineStyle(.init(lineWidth: 1)).foregroundStyle(Color.purple)
|
|
|
|
|
-//
|
|
|
|
|
-// LineMark(x: .value("Start Date", endDate), y: .value("Ratio", displayValue))
|
|
|
|
|
-// .lineStyle(.init(lineWidth: 1)).foregroundStyle(Color.purple)
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// .chartXAxis {
|
|
|
|
|
-// AxisMarks(values: .automatic(desiredCount: 6)) { _ in
|
|
|
|
|
-// AxisValueLabel(format: .dateTime.hour())
|
|
|
|
|
-// AxisGridLine(centered: true, stroke: StrokeStyle(lineWidth: 1, dash: [2, 4]))
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// .chartXScale(
|
|
|
|
|
-// domain: Calendar.current.startOfDay(for: chartScale!) ... Calendar.current.startOfDay(for: chartScale!)
|
|
|
|
|
-// .addingTimeInterval(60 * 60 * 24)
|
|
|
|
|
-// )
|
|
|
|
|
-// .chartYAxis {
|
|
|
|
|
-// AxisMarks(values: .automatic(desiredCount: 4)) { _ in
|
|
|
|
|
-// AxisValueLabel()
|
|
|
|
|
-// AxisGridLine(centered: true, stroke: StrokeStyle(lineWidth: 1, dash: [2, 4]))
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ private var basalProfileChart: some View {
|
|
|
|
|
+ Chart {
|
|
|
|
|
+ ForEach(Array(onboardingData.basalProfileItems.enumerated()), id: \.element.id) { index, item in
|
|
|
|
|
+ let displayValue = onboardingData.basalProfileRateValues[item.rateIndex]
|
|
|
|
|
+
|
|
|
|
|
+ let tzOffset = TimeZone.current.secondsFromGMT() * -1
|
|
|
|
|
+ let startDate = Date(timeIntervalSinceReferenceDate: onboardingData.basalProfileTimeValues[item.timeIndex])
|
|
|
|
|
+ .addingTimeInterval(TimeInterval(tzOffset))
|
|
|
|
|
+ let endDate = onboardingData.basalProfileItems.count > index + 1 ?
|
|
|
|
|
+ Date(
|
|
|
|
|
+ timeIntervalSinceReferenceDate: onboardingData
|
|
|
|
|
+ .basalProfileTimeValues[onboardingData.basalProfileItems[index + 1].timeIndex]
|
|
|
|
|
+ )
|
|
|
|
|
+ .addingTimeInterval(TimeInterval(tzOffset)) :
|
|
|
|
|
+ Date(timeIntervalSinceReferenceDate: onboardingData.basalProfileTimeValues.last!).addingTimeInterval(30 * 60)
|
|
|
|
|
+ .addingTimeInterval(TimeInterval(tzOffset))
|
|
|
|
|
+
|
|
|
|
|
+ RectangleMark(
|
|
|
|
|
+ xStart: .value("start", startDate),
|
|
|
|
|
+ xEnd: .value("end", endDate),
|
|
|
|
|
+ yStart: .value("rate-start", displayValue),
|
|
|
|
|
+ yEnd: .value("rate-end", 0)
|
|
|
|
|
+ ).foregroundStyle(
|
|
|
|
|
+ .linearGradient(
|
|
|
|
|
+ colors: [
|
|
|
|
|
+ Color.purple.opacity(0.6),
|
|
|
|
|
+ Color.purple.opacity(0.1)
|
|
|
|
|
+ ],
|
|
|
|
|
+ startPoint: .bottom,
|
|
|
|
|
+ endPoint: .top
|
|
|
|
|
+ )
|
|
|
|
|
+ ).alignsMarkStylesWithPlotArea()
|
|
|
|
|
+
|
|
|
|
|
+ LineMark(x: .value("End Date", startDate), y: .value("Rate", displayValue))
|
|
|
|
|
+ .lineStyle(.init(lineWidth: 1)).foregroundStyle(Color.purple)
|
|
|
|
|
+
|
|
|
|
|
+ LineMark(x: .value("Start Date", endDate), y: .value("Rate", displayValue))
|
|
|
|
|
+ .lineStyle(.init(lineWidth: 1)).foregroundStyle(Color.purple)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .chartXAxis {
|
|
|
|
|
+ AxisMarks(values: .automatic(desiredCount: 6)) { _ in
|
|
|
|
|
+ AxisValueLabel(format: .dateTime.hour())
|
|
|
|
|
+ AxisGridLine(centered: true, stroke: StrokeStyle(lineWidth: 1, dash: [2, 4]))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .chartXScale(
|
|
|
|
|
+ domain: Calendar.current.startOfDay(for: chartScale!) ... Calendar.current.startOfDay(for: chartScale!)
|
|
|
|
|
+ .addingTimeInterval(60 * 60 * 24)
|
|
|
|
|
+ )
|
|
|
|
|
+ .chartYAxis {
|
|
|
|
|
+ AxisMarks(values: .automatic(desiredCount: 4)) { _ in
|
|
|
|
|
+ AxisValueLabel()
|
|
|
|
|
+ AxisGridLine(centered: true, stroke: StrokeStyle(lineWidth: 1, dash: [2, 4]))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|