Prechádzať zdrojové kódy

Add euglucemic range.
Formatting.

Jon Mårtensson 3 rokov pred
rodič
commit
f44fd2bb6e

+ 15 - 4
FreeAPS/Sources/Modules/Stat/View/ChartsView.swift

@@ -208,19 +208,30 @@ struct ChartsView: View {
             let mapGlucose = glucose.compactMap({ each in each.glucose })
             let mapGlucose = glucose.compactMap({ each in each.glucose })
             let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
             let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
             let mapGlucoseHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
             let mapGlucoseHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
+            let mapGlucoseNormal = mapGlucose.filter({ $0 > Int16(3.8 / 0.0555) && $0 < Int16(7.9 / 0.0555) })
 
 
             HStack {
             HStack {
                 let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
                 let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
                 if value != 0 {
                 if value != 0 {
-                    Text(units == .mmolL ? "> 11" : "> 200").foregroundColor(.secondary)
+                    Text(units == .mmolL ? ">  11  " : ">  200 ").foregroundColor(.secondary)
                     Text(value.formatted()).foregroundColor(.orange)
                     Text(value.formatted()).foregroundColor(.orange)
                     Text("%").foregroundColor(.secondary)
                     Text("%").foregroundColor(.secondary)
                 }
                 }
             }.font(.caption)
             }.font(.caption)
+
+            HStack {
+                let value = Double(mapGlucoseNormal.count * 100 / mapGlucose.count)
+                if value != 0 {
+                    Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
+                    Text(value.formatted()).foregroundColor(.green)
+                    Text("%").foregroundColor(.secondary)
+                }
+            }.font(.caption)
+
             HStack {
             HStack {
                 let value = Double(mapGlucoseAcuteLow.count * 100 / mapGlucose.count)
                 let value = Double(mapGlucoseAcuteLow.count * 100 / mapGlucose.count)
                 if value != 0 {
                 if value != 0 {
-                    Text(units == .mmolL ? "< 3.3" : "< 59").foregroundColor(.secondary)
+                    Text(units == .mmolL ? "<  3.3 " : "<  59  ").foregroundColor(.secondary)
                     Text(value.formatted()).foregroundColor(.red)
                     Text(value.formatted()).foregroundColor(.red)
                     Text("%").foregroundColor(.secondary)
                     Text("%").foregroundColor(.secondary)
                 }
                 }
@@ -236,7 +247,7 @@ struct ChartsView: View {
             let mapGlucoseLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
             let mapGlucoseLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
             let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(2.6 / 0.0555) })
             let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(2.6 / 0.0555) })
 
 
-            let mapGlucoseHigh = mapGlucose.filter({ $0 > Int(8.5 / 0.0555) })
+            let mapGlucoseHigh = mapGlucose.filter({ $0 > Int(7.8 / 0.0555) })
             let mapGlucoseAcuteHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
             let mapGlucoseAcuteHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
 
 
             HStack {
             HStack {
@@ -259,7 +270,7 @@ struct ChartsView: View {
             HStack {
             HStack {
                 let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
                 let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
                 if value != 0 {
                 if value != 0 {
-                    Text(units == .mmolL ? "> 8.5" : "> 144").font(.caption).foregroundColor(.secondary)
+                    Text(units == .mmolL ? "> 7.8" : "> 140").font(.caption).foregroundColor(.secondary)
                     Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
                     Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
                     Text("%").font(.caption)
                     Text("%").font(.caption)
                 }
                 }