Просмотр исходного кода

only show every second vertical line in main chart if screenHours is too big

polscm32 2 лет назад
Родитель
Сommit
0ae1449251
1 измененных файлов с 8 добавлено и 6 удалено
  1. 8 6
      FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

+ 8 - 6
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -319,11 +319,14 @@ struct MainChartView: View {
         return ZStack {
             Path { path in
                 for hour in 0 ..< hours + hours {
-                    let x = firstHourPosition(viewWidth: fullSize.width) +
-                        oneSecondStep(viewWidth: fullSize.width) *
-                        CGFloat(hour) * CGFloat(1.hours.timeInterval)
-                    path.move(to: CGPoint(x: x, y: 0))
-                    path.addLine(to: CGPoint(x: x, y: fullSize.height - 20))
+                    if screenHours < 12 || hour % 2 == 0 {
+                        // only show every second line if screenHours is too big
+                        let x = firstHourPosition(viewWidth: fullSize.width) +
+                            oneSecondStep(viewWidth: fullSize.width) *
+                            CGFloat(hour) * CGFloat(1.hours.timeInterval)
+                        path.move(to: CGPoint(x: x, y: 0))
+                        path.addLine(to: CGPoint(x: x, y: fullSize.height - 20))
+                    }
                 }
             }
             .stroke(useColour, lineWidth: 0.15)
@@ -339,7 +342,6 @@ struct MainChartView: View {
             )
         }
     }
-
     // MARK: TO DO: CHANGE TIME LABELS TO ONLY DISPLAY EVERY SECOND LABEL WHEN SCREENHOURS IS TOO BIG
 
 //    private func timeLabelsView(fullSize: CGSize) -> some View {