Skip to content

Commit

Permalink
Add euglycemic range also to laying grouped glucose in laying TIR cha…
Browse files Browse the repository at this point in the history
…rt in stat view.
  • Loading branch information
Jon-b-m committed Jun 8, 2023
1 parent 061e6b0 commit 3d89a5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension Bolus {
}
}
header: { Text("Recommendation") }

if !state.waitForSuggestion {
Section {
HStack {
Expand Down
27 changes: 9 additions & 18 deletions FreeAPS/Sources/Modules/Stat/View/ChartsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,41 +250,32 @@ struct ChartsView: View {
let mapGlucose = glucose.compactMap({ each in each.glucose })
if !mapGlucose.isEmpty {
let mapGlucoseLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(2.6 / 0.0555) })

let mapGlucoseHigh = mapGlucose.filter({ $0 > Int(7.8 / 0.0555) })
let mapGlucoseNormal = mapGlucose.filter({ $0 > Int16(3.8 / 0.0555) && $0 < Int16(7.9 / 0.0555) })
let mapGlucoseAcuteHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })

HStack {
let value = Double(mapGlucoseAcuteLow.count * 100 / mapGlucose.count)
if value != 0 {
Text(units == .mmolL ? "< 2.6" : "< 47").font(.caption2).foregroundColor(.secondary)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .red)
Text("%").font(.caption)
}
}.padding(.horizontal, 10)
HStack {
let value = Double(mapGlucoseLow.count * 100 / mapGlucose.count)
if value != 0 {
Text(units == .mmolL ? "< 3.3" : "< 59").font(.caption2).foregroundColor(.secondary)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .red)
Text("%").font(.caption)
}
}
Spacer()
HStack {
let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
let value = Double(mapGlucoseNormal.count * 100 / mapGlucose.count)
if value != 0 {
Text(units == .mmolL ? "> 7.8" : "> 140").font(.caption).foregroundColor(.secondary)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
Text("%").font(.caption)
Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
Text(value.formatted()).foregroundColor(.green)
Text("%").foregroundColor(.secondary)
}
}.padding(.horizontal, 10)
}.font(.caption)
Spacer()
HStack {
let value = Double(mapGlucoseAcuteHigh.count * 100 / mapGlucose.count)
if value != 0 {
Text(units == .mmolL ? "> 11.0" : "> 216").font(.caption).foregroundColor(.secondary)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .red)
Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
Text("%").font(.caption)
}
}
Expand Down

0 comments on commit 3d89a5b

Please sign in to comment.