ironOS native ios app
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: fix weird chart display

+17 -18
+17 -18
ios/PinecilTime/TemperatureGraph.swift
··· 47 47 private func chartDataWithEdge(now: Date, windowSeconds: TimeInterval) -> [ChartDataPoint] { 48 48 var data: [ChartDataPoint] = [] 49 49 50 - // Add point slightly before first data point (only if data has scrolled to left edge) 50 + // Add point at left edge to extend line to screen edge 51 51 if let first = history.first { 52 52 let windowStart = now.addingTimeInterval(-windowSeconds) 53 - if first.timestamp <= windowStart { 54 - let leftEdge = windowStart.addingTimeInterval(-1) 55 - data.append(ChartDataPoint( 56 - id: "left-setpoint", 57 - timestamp: leftEdge, 58 - value: Int(first.setpoint), 59 - series: "Setpoint" 60 - )) 61 - data.append(ChartDataPoint( 62 - id: "left-temp", 63 - timestamp: leftEdge, 64 - value: Int(first.actualTemp), 65 - series: "Temp" 66 - )) 67 - } 53 + let leftEdge = windowStart.addingTimeInterval(-0.5) 54 + data.append(ChartDataPoint( 55 + id: "left-setpoint", 56 + timestamp: leftEdge, 57 + value: Int(first.setpoint), 58 + series: "Setpoint" 59 + )) 60 + data.append(ChartDataPoint( 61 + id: "left-temp", 62 + timestamp: leftEdge, 63 + value: Int(first.actualTemp), 64 + series: "Temp" 65 + )) 68 66 } 69 67 70 68 data.append(contentsOf: chartData) 71 69 72 - // Add point at right edge 70 + // Add point at right edge to extend line to screen edge (1 sec ahead) 73 71 if let last = history.last { 74 72 let rightEdge = now.addingTimeInterval(1) 75 73 data.append(ChartDataPoint( ··· 92 90 TimelineView(.animation(minimumInterval: 0.1, paused: false)) { timeline in 93 91 let now = timeline.date 94 92 let windowSeconds: TimeInterval = 6 95 - let xDomain = now.addingTimeInterval(-windowSeconds)...now 93 + let xDomain = now.addingTimeInterval(-windowSeconds)...now.addingTimeInterval(1) 96 94 97 95 Chart(chartDataWithEdge(now: now, windowSeconds: windowSeconds)) { point in 98 96 LineMark( ··· 108 106 .chartLegend(.hidden) 109 107 .chartYScale(domain: 0...500) 110 108 .chartXScale(domain: xDomain) 109 + .padding(.horizontal, -20) 111 110 } 112 111 } 113 112 }