perf(ui): 移除监控动效并精简原生图表绘制
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
/// A render frame may keep one outgoing point beyond the bounded 60-sample history.
|
||||
/// A static render frame follows the bounded sampling history without outgoing points.
|
||||
nonisolated struct PanelCurveFrame: Equatable {
|
||||
let dates: [Date]
|
||||
let series: [[Double?]]
|
||||
@@ -15,38 +15,7 @@ nonisolated struct PanelCurveFrame: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
static func domain(previousBegin: Date?, previousEnd: Date?, begin: Date, end: Date, progress: Double) -> Domain {
|
||||
let progress = min(1, max(0, progress))
|
||||
return Domain(begin: (previousBegin ?? begin).timeIntervalSinceReferenceDate * (1 - progress) + begin.timeIntervalSinceReferenceDate * progress,
|
||||
end: (previousEnd ?? end).timeIntervalSinceReferenceDate * (1 - progress) + end.timeIntervalSinceReferenceDate * progress)
|
||||
}
|
||||
|
||||
struct HorizontalTransform {
|
||||
let scale: Double
|
||||
let translation: Double
|
||||
}
|
||||
|
||||
/// Render paths once in the final domain, then map them into the original
|
||||
/// interpolated time domain. This preserves expansion as well as translation.
|
||||
static func horizontalTransform(from old: Domain, to target: Domain, progress: Double, width: Double) -> HorizontalTransform {
|
||||
let p = min(1, max(0, progress))
|
||||
let begin = old.begin * (1 - p) + target.begin * p
|
||||
let end = old.end * (1 - p) + target.end * p
|
||||
let span = end - begin, finalSpan = target.end - target.begin
|
||||
guard span.isFinite, span > 0, finalSpan.isFinite, finalSpan > 0, width.isFinite else { return HorizontalTransform(scale: 1, translation: 0) }
|
||||
return HorizontalTransform(scale: finalSpan / span, translation: (target.begin - begin) / span * width)
|
||||
}
|
||||
|
||||
static func transition(from old: Self, to new: Self) -> Self {
|
||||
guard old.dates.count > 1, old.dates.count == new.dates.count,
|
||||
Array(old.dates.dropFirst()) == Array(new.dates.dropLast()),
|
||||
let outgoing = old.dates.first else { return new }
|
||||
let series = new.series.enumerated().map { index, values -> [Double?] in
|
||||
let previous = index < old.series.count ? old.series[index] : []
|
||||
return previous.isEmpty && values.isEmpty ? [] : [previous.first ?? nil] + values
|
||||
}
|
||||
return Self(dates: [outgoing] + new.dates, series: series,
|
||||
intervals: [old.intervals.first ?? 2] + new.intervals,
|
||||
boundaryDates: new.boundaryDates.union(old.boundaryDates.intersection([outgoing])))
|
||||
static func domain(begin: Date, end: Date) -> Domain {
|
||||
Domain(begin: begin.timeIntervalSinceReferenceDate, end: end.timeIntervalSinceReferenceDate)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user