Trends: chart key shows average price per station + descriptor footer
Legend rows now show each station's average over the days shown in brackets (pence; signed +X.Xp in vs-cheapest mode, matching the list-row deltas). Footer under the key explains the figure per mode. averagePence helper (nil for empty series) + 3 tests; -showTrends becomes a permanent QA hook like -showKeySheet.
This commit is contained in:
@@ -148,6 +148,13 @@ enum FuelHistoryStore {
|
||||
}
|
||||
}
|
||||
|
||||
/// Average pence over a series' points; nil when there are no points
|
||||
/// (a station with no data shows no bracket figure in the chart key).
|
||||
static func averagePence(_ points: [PricePoint]) -> Double? {
|
||||
guard !points.isEmpty else { return nil }
|
||||
return points.reduce(0) { $0 + $1.pence } / Double(points.count)
|
||||
}
|
||||
|
||||
/// Rebase every station's series so each day's CHEAPEST favourite sits at
|
||||
/// 0 and the others show signed pence above it (mirrors the list's
|
||||
/// baseline delta pattern). Days where a station has no point are gaps.
|
||||
|
||||
Reference in New Issue
Block a user