From 7ef99cc561aaa6914bac294776a0d2227e533392 Mon Sep 17 00:00:00 2001 From: Joseph Roque Date: Mon, 9 Oct 2023 18:54:32 -0700 Subject: [PATCH] Feat: Series list charts yRange matches series low and high scores --- .../Sources/SeriesListFeature/SeriesListItem.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/Approach/Sources/SeriesListFeature/SeriesListItem.swift b/ios/Approach/Sources/SeriesListFeature/SeriesListItem.swift index e569b7047..b362a85fe 100644 --- a/ios/Approach/Sources/SeriesListFeature/SeriesListItem.swift +++ b/ios/Approach/Sources/SeriesListFeature/SeriesListItem.swift @@ -59,7 +59,7 @@ public struct SeriesListItem: View { .chartXAxis(.hidden) .chartYAxis(.hidden) .chartLegend(.hidden) - .chartYScale(domain: 0...Game.MAXIMUM_SCORE) + .chartYScale(domain: series.scoreDomain) .chartXScale(domain: 1...series.scores.count) .frame( width: contentSize.width * 0.9, @@ -139,6 +139,14 @@ extension Series.List { return nil } } + + var scoreDomain: ClosedRange { + if let scoreRange { + return max(scoreRange.lowest - 10, 0)...min(scoreRange.highest + 10, Game.MAXIMUM_SCORE) + } else { + return 0...Game.MAXIMUM_SCORE + } + } } private struct ContentSizeKey: PreferenceKey, CGSizePreferenceKey {}