Skip to content
/ sleep Public

💤 A simple graphical visualisation of my sleep data over time from Pillow iOS.

Notifications You must be signed in to change notification settings

TomPlum/sleep

Repository files navigation

💤 Sleep Health Data Visualisation

A simple 2D line chart visualisation of my sleep data as recorded by my Apple Watch using Pillow for iOS.

Examples

Data Source

Data is exported from the Pillow iOS application on my iPhone via the Export Database option in the settings. It's a fairly large (~40MB) text file committed to the codebase and served from the public directory. It's offloaded to a web-worker when the site is loaded and processed before messages are posted back to the main thread with updates and the parsed data.

web-worker-loading.png

2D Graph Views

2-Dimensional line charts to visual the change in specific sleep metrics over time. Clicking a sleep session node will render a gantt-style chart at the bottom with a breakdown of the sleep stages.

Stacked Metrics

Renders two charts stacked on top of one another so that the axes are separate. Useful for comparing two different metrics without the lines overlapping and creating noise. stacked-metrics.png

Compare Metrics

Renders a single chart with two lines for each of the selected metrics.

compare-metrics.png comparison-ui.png

Single Metrics

Renders a single line chart for the selected metric.

Sleep Quality (%)

quality.png

Deep Sleep (% of session duration)

deep.png

Light Sleep (% of session duration)

light.png

REM Sleep (% of session duration)

rem.png

Awake Time (% of session duration)

awake.png

Session Duration (% of 8 hours)

duration.png

3D Experimental View

3d-experimental.png

Thanks to

To Do

  • Date parsing not working in Safari and breaks graph
  • Update session breakdown to include data like the ios app does
  • Can we get heart rate data from the raw database export?
  • There are 58k sleep stage records mapped -> undefined, why?
  • If you change the date-range and the selected session is no longer in that range, what should happen?
  • Web worker makes about 800 cached resource requests while its loading
  • Looks like the line chart redraws from new each time now instead of tweening. Is it the loop?
  • Move sleep colours to a common stylesheet