Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sleep Data Chart #503

Merged
merged 1 commit into from
Jan 2, 2024
Merged

Add Sleep Data Chart #503

merged 1 commit into from
Jan 2, 2024

Conversation

sternetj
Copy link
Contributor

Changes

  • Adds a new my data chart type called SleepChart
  • Sleep chart has different views for the single day and multi day views
  • Single day shows a minute by minute break down of sleep levels for corresponding sleep observations
  • Multi day shows total sleep duration for week and month by day and shows an average sleep duration for year by each month

Screenshots

@coveralls
Copy link

Pull Request Test Coverage Report for Build 7263537534

  • 186 of 191 (97.38%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 84.468%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/components/MyData/SleepChart/MultiDayChart.tsx 51 53 96.23%
src/components/MyData/SleepChart/DailyChart.tsx 63 66 95.45%
Totals Coverage Status
Change from base Build 7224988698: 0.6%
Covered Lines: 3414
Relevant Lines: 3930

💛 - Coveralls

{component.type === 'SleepChart' && (
<SleepChart
{...component}
title="Sleep Analysis"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use i18n?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch. That shouldn't be there. The chart title should come from the app config. I'll update this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this in a followup pull request.

.range([0, common.plotAreaWidth])
.domain([new Date(start ?? 0), new Date(end ?? 0)]);

setChartData({ sleepData: newSleepData, xDomain: newXDomain, dateRange });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like we've talked about, whether in this hook or elsewhere, I foresee the need to filter newSleepData down to handle multiple sleep records per evening (e.g. one from Oura, one from Garmin -> both synced in from Apple Health). Unless that logic is already in place elsewhere, just keep it in mind (as perhaps a separate task to eventually get to). Excited to try this out with my own data, which would serve as an example of that scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of forgot about that discussion. I think it will likely have some display issues with the current solution. I look into it and follow up with a fix.

3: t('sleep-analysis-type-rem', 'REM'),
2: t('sleep-analysis-type-light', 'Light'),
1: t('sleep-analysis-type-deep', 'Deep'),
}[value] ?? '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 so cool to see these normalized component codings come together!

Copy link
Contributor

@markdlv markdlv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@sternetj sternetj merged commit e338aec into master Jan 2, 2024
3 checks passed
@sternetj sternetj deleted the sleep-analysis-chart branch January 2, 2024 15:21
Copy link

github-actions bot commented Jan 2, 2024

🎉 This PR is included in version 11.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Has been released to the package repository (NPM, etc) label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Has been released to the package repository (NPM, etc)
Projects
None yet
3 participants