@@ -86,8 +86,8 @@ struct HeartChartView: View {
8686 points. map ( { $0. date } ) . max ( ) ?? Date ( )
8787 }
8888
89- let heartColor = Color ( red : 0.996 , green : 0.212 , blue : 0.369 )
90- let darkHeartColor = Color ( red: 0.369 , green: 0.090 , blue: 0.145 )
89+ let heartColor = Color . pink
90+ let darkHeartColor = Color ( red: 0.369 , green: 0.090 , blue: 0.145 ) // darkened version of heartColor
9191
9292 func isSingleReading( _ point: HeartChartDataPoint ) -> Bool {
9393 point. min == point. max
@@ -197,16 +197,15 @@ struct HeartChartView: View {
197197 @available ( iOS 17 , * )
198198 var scrollableChart : some View {
199199 let xMin = Calendar . current. startOfDay ( for: earliestDate)
200- //let xMax = Calendar.current.date(byAdding: .day, value: 2, to: Calendar.current.startOfDay(for: latestDate)) ?? latestDate
201- let xMax = Calendar . current. startOfDay ( for: latestDate) + 86400 + 3600
200+ let xMax = Calendar . current. startOfDay ( for: latestDate) + 86400 + 3600 // + one day and an hour, fixes the snappy scrolling otherwise breaking sometimes
202201 let yMin = displayedMin - 20
203202 let yMax = displayedMax + 20
204203
205204 return Chart {
206205 if let selectedViewHour {
207- RuleMark ( x: . value( " Selected Hour " , selectedViewHour. date, unit: . hour) )
208- . foregroundStyle ( . secondary )
209- }
206+ RuleMark ( x: . value( " Selected Hour " , selectedViewHour. date, unit: . hour) )
207+ . foregroundStyle ( Color . gray )
208+ }
210209
211210 ForEach ( points) { point in
212211 chartContent ( for: point)
@@ -268,7 +267,9 @@ struct HeartChartView: View {
268267 . font ( . system( . title, design: . rounded) )
269268 . foregroundColor ( . primary)
270269 + Text( " BPM " )
271- Text ( " \( rangeFirstHour. formatted ( . dateTime. month ( . abbreviated) . day ( ) ) ) , \( rangeFirstHour. formatted ( . dateTime. hour ( ) ) ) – \( rangeLastHour. formatted ( . dateTime. hour ( ) ) ) " )
270+
271+ let style = Date . FormatStyle ( ) . hour ( . defaultDigits( amPM: . abbreviated) )
272+ Text ( " \( rangeFirstHour. formatted ( . dateTime. month ( . abbreviated) . day ( ) ) ) , \( rangeFirstHour. formatted ( style) ) – \( rangeLastHour. formatted ( style) ) · \( selectedViewHour. values. count) \( selectedViewHour. values. count == 1 ? " reading " : " readings " ) · \( Int ( selectedViewHour. average) ) BPM avg " )
272273 . foregroundColor ( . secondary)
273274 . font ( . subheadline)
274275 }
@@ -299,13 +300,6 @@ struct HeartChartView: View {
299300 }
300301 }
301302 . listRowBackground ( Color . clear)
302- /*
303- if points.count >= 3 {
304- Section {
305- Text("Today your heart rate reached a high of \(displayedMax), and dropped to a low of \(displayedMin) BPM.")
306- }
307- }
308- */
309303 }
310304 . onAppear {
311305 points = heartPoints ( )
0 commit comments