DummyCharts.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Charts
  2. import Foundation
  3. import SwiftUI
  4. extension MainChartView {
  5. /// empty chart that just shows the Y axis and Y grid lines. Created separately from `mainChart` to allow main chart to scroll horizontally while having a fixed Y axis
  6. var staticYAxisChart: some View {
  7. Chart {
  8. /// high and low threshold lines
  9. if thresholdLines {
  10. RuleMark(y: .value("High", highGlucose)).foregroundStyle(Color.loopYellow)
  11. .lineStyle(.init(lineWidth: 1, dash: [5]))
  12. RuleMark(y: .value("Low", lowGlucose)).foregroundStyle(Color.loopRed)
  13. .lineStyle(.init(lineWidth: 1, dash: [5]))
  14. }
  15. }
  16. .id("DummyMainChart")
  17. .frame(minHeight: geo.size.height * 0.28)
  18. .frame(width: screenSize.width - 10)
  19. .chartXAxis { mainChartXAxis }
  20. .chartXScale(domain: startMarker ... endMarker)
  21. .chartXAxis(.hidden)
  22. .chartYAxis { mainChartYAxis }
  23. .chartYScale(domain: units == .mgdL ? minValue ... maxValue : minValue.asMmolL ... maxValue.asMmolL)
  24. .chartLegend(.hidden)
  25. }
  26. var dummyBasalChart: some View {
  27. Chart {}
  28. .id("DummyBasalChart")
  29. .frame(minHeight: geo.size.height * 0.05)
  30. .frame(width: screenSize.width - 10)
  31. .chartXAxis { basalChartXAxis }
  32. .chartXAxis(.hidden)
  33. .chartYAxis(.hidden)
  34. .chartLegend(.hidden)
  35. }
  36. var dummyCobChart: some View {
  37. Chart {
  38. drawCOB(dummy: true)
  39. }
  40. .id("DummyCobChart")
  41. .frame(minHeight: geo.size.height * 0.12)
  42. .frame(width: screenSize.width - 10)
  43. .chartXScale(domain: startMarker ... endMarker)
  44. .chartXAxis { basalChartXAxis }
  45. .chartXAxis(.hidden)
  46. .chartYAxis { cobChartYAxis }
  47. .chartYAxis(.hidden)
  48. .chartYScale(domain: minValueCobChart ... maxValueCobChart)
  49. .chartLegend(.hidden)
  50. }
  51. }