feat(ui): 趋势图跳过无值节点并接续有效数据
This commit is contained in:
@@ -4,7 +4,17 @@ import Foundation
|
||||
static func main() {
|
||||
let dates = (0..<60).map { Date(timeIntervalSinceReferenceDate: Double($0 * 2)) }
|
||||
let runs = PanelCurveGeometry.runs(dates: Array(dates.prefix(6)), values: [0, 0.5, nil, .nan, 0.8, 1])
|
||||
precondition(runs.count == 2 && runs[0].count == 2 && runs[1].count == 2)
|
||||
precondition(runs.count == 1 && runs[0].map(\.value) == [0, 0.5, 0.8, 1])
|
||||
precondition(runs[0].map(\.date) == [dates[0], dates[1], dates[4], dates[5]],
|
||||
"Skip missing vertices without shifting real timestamps or dropping valid zeroes")
|
||||
let sparseDates = Array(dates.prefix(5))
|
||||
precondition(PanelCurveGeometry.runs(dates: sparseDates, values: [nil, 0, .infinity, 0.8, nil]).first?.map(\.value) == [0, 0.8])
|
||||
precondition(PanelCurveGeometry.runs(dates: sparseDates, values: [nil, .nan, .infinity, -.infinity, nil]).isEmpty)
|
||||
precondition(PanelCurveGeometry.runs(dates: sparseDates, values: [0, nil, nil, nil, 1],
|
||||
boundaryDates: [dates[2]]).count == 2, "A boundary on an empty sample must still break the curve")
|
||||
let absent = [0.0, 2, 20, 22].map { Date(timeIntervalSinceReferenceDate: $0) }
|
||||
precondition(PanelCurveGeometry.runs(dates: absent, values: [0, nil, nil, 1]).count == 2,
|
||||
"A real sampling gap must remain visible even when its endpoints have missing values")
|
||||
precondition(PanelCurveGeometry.runs(dates: [dates[0], dates[4]], values: [0.3, 0.5]).count == 2)
|
||||
precondition(PanelCurveGeometry.runs(dates: [dates[1], dates[0]], values: [0.3, 0.5]).count == 2)
|
||||
precondition(PanelCurveGeometry.runs(dates: dates, values: []).isEmpty)
|
||||
@@ -25,6 +35,6 @@ import Foundation
|
||||
precondition(abs(irregular.position(dates[2]) - 0.25) < 0.000001)
|
||||
let single = PanelCurveFrame.domain(begin: dates[0], end: dates[0])
|
||||
precondition(single.position(dates[0]) == 1)
|
||||
print("PASS: static timestamp domain, bounded history, missing/nonfinite data, short series, cadence continuity and real pause boundaries")
|
||||
print("PASS: static timestamp domain, skipped missing/nonfinite vertices, valid zeroes, unchanged timestamps, cadence continuity and real breaks on empty samples")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user