feat(ui): 趋势图跳过无值节点并接续有效数据
This commit is contained in:
@@ -24,7 +24,7 @@ struct MiniTrendChart: View {
|
||||
run.removeAll(keepingCapacity: true)
|
||||
}
|
||||
for (index, value) in values.enumerated() {
|
||||
guard let value, value.isFinite else { appendRun(); continue }
|
||||
guard let value, value.isFinite else { continue }
|
||||
let x = size.width * CGFloat(index + MetricHistory.capacity - values.count) / CGFloat(MetricHistory.capacity - 1)
|
||||
run.append(CGPoint(x: x, y: 2 + (size.height - 4) * (1 - min(1, max(0, value)))))
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ nonisolated enum PanelCurveGeometry {
|
||||
var run: [Sample] = []
|
||||
func flush() { if !run.isEmpty { result.append(run); run.removeAll(keepingCapacity: true) } }
|
||||
for index in dates.indices {
|
||||
guard index < values.count, let value = values[index], value.isFinite else { flush(); continue }
|
||||
if index > 0 && (boundaryDates.contains(dates[index]) || dates[index].timeIntervalSince(dates[index - 1]) > allowedGap(at: index, intervals: intervals, fallback: maximumGap) || dates[index] <= dates[index - 1]) { flush() }
|
||||
// Missing values do not create vertices, but their timestamps can still carry a real break.
|
||||
guard index < values.count, let value = values[index], value.isFinite else { continue }
|
||||
run.append(Sample(date: dates[index], value: value))
|
||||
}
|
||||
flush()
|
||||
|
||||
@@ -8,7 +8,7 @@ enum TrendValueFormat {
|
||||
case watts
|
||||
}
|
||||
|
||||
/// Bounded, timestamp-based static curves. Gaps remain gaps; no per-sample animation task.
|
||||
/// Static curves skip missing vertices, retaining timestamps and explicit sampling breaks.
|
||||
struct PanelTrendChart: View {
|
||||
let dates: [Date]
|
||||
let first: [Double?]
|
||||
|
||||
Reference in New Issue
Block a user