Apple Health Frameworks

Nov 29 2022 Swift 5, iOS 15, Xcode 13

Part 3: Take Advantage of CareKit & ResearchKit

13. Create OCKDataSeriesConfiguration

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 12. Extract OCKOutcomeValue from ORKTaskResult Next episode: 14. Show Data in Different Charts

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

This video Create OCKDataSeriesConfiguration was last updated on Nov 29 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Part 3, Episode 14, Create OCKDataSeriesConfiguration

In this episode, I want to show you how to create different charts using CareKitUI and CareKitStore.

    let muscleSeries = OCKDataSeriesConfiguration(
      taskID: TaskModel.checkIn.rawValue,
      legendTitle: "Muscle Pain (1-10)",
      gradientStartColor: UIColor(red: 1, green: 0.462745098, blue: 0.368627451, alpha: 1),
      gradientEndColor: UIColor(red: 1, green: 0.462745098, blue: 0.368627451, alpha: 1),
      markerSize: 10,
      eventAggregator: .custom { events in
        events
          .first?
          .answer(kind: IdentifierModel.checkinMuscle.rawValue)
          ?? 0
      }
    )
let  headacheSeries = OCKDataSeriesConfiguration(
      taskID: TaskModel.checkIn.rawValue,
      legendTitle: "Headache (1-10)",
      gradientStartColor: UIColor(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1),
      gradientEndColor: UIColor(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1),
      markerSize: 10,
      eventAggregator: .custom { events in
        events
          .first?
          .answer(kind: IdentifierModel.checkinHeadache.rawValue)
          ?? 0
      }
    )
    let tirednessSeries = OCKDataSeriesConfiguration(
      taskID: TaskModel.checkIn.rawValue,
      legendTitle: "Tiredness (0-10)",
      gradientStartColor: UIColor(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1),
      gradientEndColor: UIColor(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1),
      markerSize: 10,
      eventAggregator: .custom { events in
        events
          .first?
          .answer(kind: IdentifierModel.checkinTiredness.rawValue)
          ?? 0
      }
    )
    let feverSeries = OCKDataSeriesConfiguration(
      taskID: TaskModel.checkIn.rawValue,
      legendTitle: "Temprature (35°C-42°C)",
      gradientStartColor: UIColor(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1),
      gradientEndColor: UIColor(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1),
      markerSize: 2,
      eventAggregator: .custom { events in
        events
          .first?
          .answer(kind: IdentifierModel.checkinFever.rawValue)
          ?? 0
      }
    )
let rangeSeries = OCKDataSeriesConfiguration(
      taskID: TaskModel.motionCheck.rawValue,
      legendTitle: "Range of Motion (degrees)",
      gradientStartColor: UIColor(red: 0.3647058904, green: 0.06666667014, blue: 0.9686274529, alpha: 1),
      gradientEndColor: UIColor(red: 0.3647058904, green: 0.06666667014, blue: 0.9686274529, alpha: 1),
      markerSize: 3,
      eventAggregator: .custom { events in
        events
          .first?
          .answer(kind: #keyPath(ORKRangeOfMotionResult.range))
          ?? 0
      }
    )