Skip to content

Add vitamin D history screen with W/M/3M bar chart and body-store trend line - #26

Open
JWAY21 wants to merge 5 commits into
jackjackbits:mainfrom
JWAY21:feature/history-view
Open

Add vitamin D history screen with W/M/3M bar chart and body-store trend line#26
JWAY21 wants to merge 5 commits into
jackjackbits:mainfrom
JWAY21:feature/history-view

Conversation

@JWAY21

@JWAY21 JWAY21 commented Jun 7, 2026

Copy link
Copy Markdown

Adds a Vitamin D History sheet, opened via a chart icon (chart.bar.fill) in the app header. Reads daily totals from HealthKit via the existing getVitaminDHistory(days:) method and renders individual daily bars using Swift Charts.

Periods — all show one bar per day:

  • W: last 7 days
  • M: last 30 days
  • 3M: last 90 days

Body-store trend line (yellow) based on the pharmacokinetics of 25-hydroxyvitamin D (calcidiol):

  • Decay = 2^(−1/20) ≈ 0.966/day, matching the ~20-day half-life of circulating vitamin D
  • Recent days are weighted most heavily; the MA is seeded with 60 days of extra history so the first bar starts with an accurate value rather than zero
  • Rising line = consistently building stores; falling line = not getting enough sun

The average for the selected period is shown prominently above the chart. Respects the IU/mcg unit preference from AppStorage alongside the rest of the app. Default period is W.

Jesse Wales and others added 4 commits June 7, 2026 10:15
Adds a HistoryView sheet, opened via a chart icon in the header.
Reads from HealthKit via the existing getVitaminDHistory(days:)
method and displays daily/weekly/monthly totals as a bar chart
using Swift Charts. The average for the selected period is shown
prominently above the chart. Respects the IU/mcg unit preference
from AppStorage alongside the rest of the app.

Periods:
- D: last 7 days, one bar per day
- W: last 4 weeks, one bar per week
- M: last 3 months, one bar per month

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All four periods (D/W/M/3M) now show individual daily bars rather
than bucketed weekly or monthly totals, matching the Apple Health
bar-chart style.

Adds a 3M period (90 days).

Adds a half-life-weighted moving average line:
- decay = 2^(-1/20) ≈ 0.966 per day, matching the ~20-day half-life
  of circulating 25-hydroxyvitamin D (calcidiol)
- Each past day's contribution decays exponentially, so the line
  represents the body's effective accumulated vitamin D level
- The MA is seeded with 60 days of extra history (3 × half-life)
  so even the first bar of the shortest view starts accurately
- Rising line = building stores; falling line = falling behind

Legend and brief scientific explanation shown below the chart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The daily (7-day) view is redundant given the weekly tab already
shows fine-grained daily bars. Periods are now W (28 days),
M (30 days), and 3M (90 days). Default selection is W.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All three periods show individual daily bars (no bucketing):
- W  = 28 days of daily bars
- M  = 30 days of daily bars
- 3M = 90 days of daily bars

Adds a yellow half-life-weighted moving average line:
- Decay = 2^(-1/20) ≈ 0.966/day, matching the ~20-day half-life
  of circulating 25-hydroxyvitamin D (calcidiol)
- MA is seeded with 60 days (3 × half-life) of extra history so
  the first bar in any view starts with an accurate value
- Rising line = consistently building stores
- Falling line = not getting enough sun to maintain levels
- Legend and brief explanation shown below the chart

Respects the IU/mcg unit preference from AppStorage.
Default period is W (4 weeks).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@JWAY21 JWAY21 changed the title Add vitamin D history screen with D/W/M bar chart Add vitamin D history screen with W/M/3M bar chart and body-store trend line Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant