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
Open
Add vitamin D history screen with W/M/3M bar chart and body-store trend line#26JWAY21 wants to merge 5 commits into
JWAY21 wants to merge 5 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 existinggetVitaminDHistory(days:)method and renders individual daily bars using Swift Charts.Periods — all show one bar per day:
Body-store trend line (yellow) based on the pharmacokinetics of 25-hydroxyvitamin D (calcidiol):
The average for the selected period is shown prominently above the chart. Respects the IU/mcg unit preference from
AppStoragealongside the rest of the app. Default period is W.