From ff5b160db95f1d30d624d4ba084a752b1de2cb32 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 1 Apr 2023 03:12:10 -0700 Subject: [PATCH] Chart updates on device metrics --- Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 56 +++++++++---------- de.lproj/Localizable.strings | 1 - en.lproj/Localizable.strings | 1 - zh-Hans.lproj/Localizable.strings | 1 - 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index 9bf5bed7..05e53f70 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -19,7 +19,7 @@ struct DeviceMetricsLog: View { var body: some View { - let oneDayAgo = Calendar.current.date(byAdding: .day, value: -3, to: Date()) + let oneDayAgo = Calendar.current.date(byAdding: .hour, value: -6, to: Date()) let deviceMetrics = node.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0")).reversed() as? [TelemetryEntity] ?? [] let chartData = deviceMetrics .filter { $0.time != nil && $0.time! >= oneDayAgo! } @@ -29,47 +29,45 @@ struct DeviceMetricsLog: View { if chartData.count > 0 { - GroupBox(label: Label("battery.level.trend", systemImage: "battery.100")) { + GroupBox() {//label: Label("battery.level.trend", systemImage: "battery.100")) { Chart(chartData, id: \.self) { - - PointMark( - x: .value("Time", $0.time!, unit: .hour), - y: .value("Value", $0.channelUtilization) - ) - .foregroundStyle(.green) LineMark( - x: .value("Time", $0.time!, unit: .hour), - y: .value("Value", $0.channelUtilization) - ) - .foregroundStyle(.green) - .interpolationMethod(.catmullRom) - - PointMark( - x: .value("Time", $0.time!, unit: .hour), + x: .value("Hour", $0.time!.formattedDate(format: "ha")), y: .value("Value", $0.batteryLevel) ) .foregroundStyle(.blue) - - LineMark( - x: .value("Time", $0.time!, unit: .hour), + PointMark( + x: .value("Hour", $0.time!.formattedDate(format: "ha")), y: .value("Value", $0.batteryLevel) ) .foregroundStyle(.blue) +// LineMark( +// x: .value("Hour", $0.time!.formattedDate(format: "ha")), +// y: .value("Value", $0.channelUtilization) +// ) +// .foregroundStyle(.green) +// .interpolationMethod(.catmullRom) PointMark( - //x: .value("Hour", $0.time!.formattedDate(format: "ha")), - x: .value("Time", $0.time!, unit: .hour), + x: .value("Hour", $0.time!.formattedDate(format: "ha")), + y: .value("Value", $0.channelUtilization) + ) + .foregroundStyle(.green) + +// LineMark( +// x: .value("Time", $0.time!, unit: .hour), +// y: .value("Value", $0.airUtilTx) +// ) +// .foregroundStyle(.red) + PointMark( + x: .value("Hour", $0.time!.formattedDate(format: "ha")), + //x: .value("Time", $0.time!, unit: .hour), y: .value("Value", $0.airUtilTx) ) .foregroundStyle(.red) - LineMark( - x: .value("Time", $0.time!, unit: .hour), - y: .value("Value", $0.airUtilTx) - ) - .foregroundStyle(.red) } // Set color for each data in the chart .chartForegroundStyleScale([ @@ -78,9 +76,9 @@ struct DeviceMetricsLog: View { "Airtime": .red ]) .chartLegend(position: .automatic, alignment: .bottom) - .chartXAxis { - AxisMarks(values: .stride(by: .hour)) - } +// .chartXAxis { +// AxisMarks(values: .stride(by: .hour)) +// } //.frame(height: 200) } } diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index d42c9caa..851303bc 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -18,7 +18,6 @@ "available.radios"="Geräte in der Nähe"; "automatic.detection"="Automatische erkennung"; "battery.level"="Batterie Ladung"; -"battery.level.trend"="Batterie Ladungstrend"; "ble.name"="BLE Name";"ble.connection.timeout %d %@"="Verbindung nach %d Versuchen zu %@ fehlgeschlagen. Evtl. hilft es, die Verbindung unter Einstellungen > Bluetooth manuell zu löschen."; "ble.connection.timeout %d %@"="Verbindung nach %d Versuchen zu %@ fehlgeschlagen. Evtl. hilft es, die Verbindung unter Einstellungen > Bluetooth manuell zu löschen."; "ble.errorcode.6 %@"="%@ Die App wird automatisch zum präferierten Gerät wiederverbinden, sobald es in Reichweite kommt."; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index b0ad7edc..dd6b1e2e 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -18,7 +18,6 @@ "available.radios"="Available Radios"; "automatic.detection"="Automatic Detection"; "battery.level"="Battery Level"; -"battery.level.trend"="Battery Level Trend"; "ble.name"="BLE Name"; "ble.connection.timeout %d %@"="Connection failed after %d attempts to connect to %@. You may need to forget your device under Settings > Bluetooth."; "ble.errorcode.6 %@"="%@ The app will automatically reconnect to the preferred radio if it comes back in range."; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index f0f54149..1fad751b 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -18,7 +18,6 @@ "available.radios"="可用的电台"; "automatic.detection"="自动识别"; "battery.level"="电池电量"; -"battery.level.trend"="电池电量趋势"; "ble.name"="蓝牙名称"; "ble.connection.timeout %d %@"="尝试连接%@失败,你可能需要在系统设置的蓝牙选项中忽略该电台。"; "ble.errorcode.6 %@"="%@ 如果在首选电台的旁边,App 将会自动重连。";