mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Chart updates on device metrics
This commit is contained in:
parent
7abe9bfc8e
commit
ff5b160db9
4 changed files with 27 additions and 32 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.";
|
||||
|
|
|
|||
|
|
@ -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.";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
"available.radios"="可用的电台";
|
||||
"automatic.detection"="自动识别";
|
||||
"battery.level"="电池电量";
|
||||
"battery.level.trend"="电池电量趋势";
|
||||
"ble.name"="蓝牙名称";
|
||||
"ble.connection.timeout %d %@"="尝试连接%@失败,你可能需要在系统设置的蓝牙选项中忽略该电台。";
|
||||
"ble.errorcode.6 %@"="%@ 如果在首选电台的旁边,App 将会自动重连。";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue