diff --git a/FuelBoard/TrendsView.swift b/FuelBoard/TrendsView.swift index 9ed58d4..bdc2a24 100644 --- a/FuelBoard/TrendsView.swift +++ b/FuelBoard/TrendsView.swift @@ -205,13 +205,21 @@ struct TrendsView: View { } private var chart: some View { - Chart(displaySeries) { history in - ForEach(history.points) { point in - LineMark( - x: .value("Date", point.date), - y: .value("Price", point.pence) - ) - .foregroundStyle(seriesColor(index(of: history.stationID))) + // NOTE: each LineMark MUST carry an explicit `series:` — without it + // Swift Charts merges every station's points into ONE polyline + // (points connect across stations, so only the first station's line + // is recognisable). The outer ForEach keeps one chart with N series; + // per-mark foregroundStyle then colours each series from the palette. + Chart { + ForEach(displaySeries) { history in + ForEach(history.points) { point in + LineMark( + x: .value("Date", point.date), + y: .value("Price", point.pence), + series: .value("Station", history.name) + ) + .foregroundStyle(seriesColor(index(of: history.stationID))) + } } } .chartXAxis {