|
|
@@ -345,14 +345,16 @@ struct MainChartView: View {
|
|
|
return ZStack {
|
|
|
Path { path in
|
|
|
for hour in 0 ..< hours + hours {
|
|
|
- if screenHours < 12 || hour % 2 == 0 {
|
|
|
- // only show every second line if screenHours is too big
|
|
|
- let x = firstHourPosition(viewWidth: fullSize.width) +
|
|
|
+ if screenHours >= 12 && hour % 2 == 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ 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))
|
|
|
- }
|
|
|
+ ) * zoomScale
|
|
|
+ path.move(to: CGPoint(x: x, y: 0))
|
|
|
+ path.addLine(to: CGPoint(x: x, y: fullSize.height - 20))
|
|
|
}
|
|
|
}
|
|
|
.stroke(useColour, lineWidth: 0.15)
|
|
|
@@ -369,41 +371,34 @@ 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 {
|
|
|
-// let format = screenHours > 6 ? date24Formatter : dateFormatter
|
|
|
-// return ZStack {
|
|
|
-// // X time labels
|
|
|
-// ForEach(0 ..< hours + hours) { hour in
|
|
|
-// Text(format.string(from: firstHourDate().addingTimeInterval(hour.hours.timeInterval)))
|
|
|
-// .font(.caption)
|
|
|
-// .position(
|
|
|
-// x: firstHourPosition(viewWidth: fullSize.width) +
|
|
|
-// oneSecondStep(viewWidth: fullSize.width) *
|
|
|
-// CGFloat(hour) * CGFloat(1.hours.timeInterval),
|
|
|
-// y: 10.0
|
|
|
-// )
|
|
|
-// .foregroundColor(.secondary)
|
|
|
-// }
|
|
|
-// }.frame(maxHeight: 20)
|
|
|
-// }
|
|
|
-
|
|
|
private func timeLabelsView(fullSize: CGSize) -> some View {
|
|
|
let format = screenHours > 6 ? date24Formatter : dateFormatter
|
|
|
return ZStack {
|
|
|
// X time labels
|
|
|
- ForEach(0 ..< hours + hours) { hour in
|
|
|
- if screenHours >= 12 && hour % 2 == 1 {
|
|
|
- // only show every second time label if screenHours is too big
|
|
|
- EmptyView()
|
|
|
- } else {
|
|
|
+ ForEach(0 ..< hours + hours, id: \.self) { hour in
|
|
|
+ // show every other label
|
|
|
+ if screenHours >= 12 && hour % 2 == 0 {
|
|
|
+ Text(format.string(from: firstHourDate().addingTimeInterval(hour.hours.timeInterval)))
|
|
|
+ .font(.caption)
|
|
|
+ .position(
|
|
|
+ x: (
|
|
|
+ firstHourPosition(viewWidth: fullSize.width) +
|
|
|
+ oneSecondStep(viewWidth: fullSize.width) *
|
|
|
+ CGFloat(hour) * CGFloat(1.hours.timeInterval)
|
|
|
+ ) * zoomScale,
|
|
|
+ y: 10.0
|
|
|
+ )
|
|
|
+ .foregroundColor(.secondary)
|
|
|
+ } else if screenHours < 12 {
|
|
|
+ // show every label
|
|
|
Text(format.string(from: firstHourDate().addingTimeInterval(hour.hours.timeInterval)))
|
|
|
.font(.caption)
|
|
|
.position(
|
|
|
- x: firstHourPosition(viewWidth: fullSize.width) +
|
|
|
- oneSecondStep(viewWidth: fullSize.width) *
|
|
|
- CGFloat(hour) * CGFloat(1.hours.timeInterval),
|
|
|
+ x: (
|
|
|
+ firstHourPosition(viewWidth: fullSize.width) +
|
|
|
+ oneSecondStep(viewWidth: fullSize.width) *
|
|
|
+ CGFloat(hour) * CGFloat(1.hours.timeInterval)
|
|
|
+ ) * zoomScale,
|
|
|
y: 10.0
|
|
|
)
|
|
|
.foregroundColor(.secondary)
|