feat(ui): 趋势图跳过无值节点并接续有效数据
This commit is contained in:
@@ -28,7 +28,17 @@ import QuartzCore
|
||||
plot.needsDisplay = false; plot.configure(continuous)
|
||||
precondition(!plot.needsDisplay, "Identical inputs must not invalidate the plot")
|
||||
plot.configure(input([0.8,0.8,nil,0.8]))
|
||||
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) == 0, "Missing values must leave a real gap")
|
||||
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) > 10, "Missing vertices must connect the surrounding valid points")
|
||||
plot.configure(input([0.8,nil,.nan,0.8]))
|
||||
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) > 10)
|
||||
plot.configure(.init(frame: .init(dates: dates, series: [[0.8,nil,nil,0.8]],
|
||||
intervals: [2,2,2,2], boundaryDates: [dates[2]]), colors: [.red], scales: [1], maximumGap: 5))
|
||||
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) == 0,
|
||||
"A pause boundary on a missing vertex must still leave a real gap")
|
||||
var missingHover = input([0.8,0.8,nil,0.8]); missingHover.hoveredIndex = 2
|
||||
plot.configure(missingHover)
|
||||
let dots = plot.layer!.sublayers!.last as! CAShapeLayer
|
||||
precondition(dots.path == nil, "Connecting a missing value must not invent a measured hover dot")
|
||||
plot.configure(input([nil,nil,nil,nil]))
|
||||
precondition(redPixels(bitmap(plot)) == 0)
|
||||
let changedDates = [0.0, 2, 8, 10].map { Date(timeIntervalSinceReferenceDate: $0) }
|
||||
|
||||
@@ -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