DummyCharts.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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(
  24. domain: units == .mgdL ? state.minYAxisValue ... state.maxYAxisValue : state.minYAxisValue.asMmolL ... state
  25. .maxYAxisValue.asMmolL
  26. )
  27. .chartLegend(.hidden)
  28. }
  29. var dummyBasalChart: some View {
  30. Chart {}
  31. .id("DummyBasalChart")
  32. .frame(minHeight: geo.size.height * 0.05)
  33. .frame(width: screenSize.width - 10)
  34. .chartXAxis { basalChartXAxis }
  35. .chartXAxis(.hidden)
  36. .chartYAxis(.hidden)
  37. .chartLegend(.hidden)
  38. }
  39. var dummyCobChart: some View {
  40. Chart {
  41. drawCOB(dummy: true)
  42. }
  43. .id("DummyCobChart")
  44. .frame(minHeight: geo.size.height * 0.12)
  45. .frame(width: screenSize.width - 10)
  46. .chartXScale(domain: startMarker ... endMarker)
  47. .chartXAxis { basalChartXAxis }
  48. .chartXAxis(.hidden)
  49. .chartYAxis { cobChartYAxis }
  50. .chartYAxis(.hidden)
  51. .chartYScale(domain: state.minValueCobChart ... state.maxValueCobChart)
  52. .chartLegend(.hidden)
  53. }
  54. }