Skip to content

Heart rate chart redesign#159

Open
tituscmd wants to merge 25 commits into
InfiniTimeOrg:rebuildfrom
tituscmd:hrm_chart
Open

Heart rate chart redesign#159
tituscmd wants to merge 25 commits into
InfiniTimeOrg:rebuildfrom
tituscmd:hrm_chart

Conversation

@tituscmd
Copy link
Copy Markdown
Contributor

@tituscmd tituscmd commented May 5, 2026

Hey all!

This PR reworks the heart rate chart to more closely match the style of Apple Health.

Instead of the previous line/area chart, it now uses a range bar chart that groups readings by the hour, showing the min/max range as a darker bar and the average of that hour as a brighter dot overlaid on top. The header still shows the BPM range and date for the day you're currently viewing, and now fluidly updates when you navigate to a different day.

Since smooth horizontal scrolling requires iOS 17+, I went with a chevron-based day navigation approach instead to keep things compatible with iOS 16. The chart fetches up to a week of data, using the existing weekPredicate in ChartManager, instead of the previously used dayPredicate. Only the data from the current week is fetched, not the last 7 days, similar to how the step chart operates.

The Y axis scales dynamically to the visible data rather than being hardcoded, which I think makes it a lot more readable especially when readings are close together.

Hope you like it 🙂

image

@liamcharger liamcharger added enhancement New feature or request ui Improvements or changes to the user interface labels May 5, 2026
Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
@liamcharger
Copy link
Copy Markdown
Collaborator

Another thing, you can remove "Apple Charts with date range selection" from the readme

Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
@liamcharger
Copy link
Copy Markdown
Collaborator

liamcharger commented May 14, 2026

Ok so I just pushed a rather large commit. I cleaned up a couple things:

  • The fixed and scrollable charts were completely independent of each other when they could use some of the same components/variables
  • There was some unnecessary listeners that I replaced with computed properties (updateDisplayed, updateYScale)
  • Oh I also changed the position of the chevrons on the fixed chart

One of the main things to keep in mind is to keep the code as small as possible; I saw a few components that could be shrunk or extracted. I'll publish some best practices at some point you can glance at :)

Also feel free to let me know if I broke anything :)))

Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
@liamcharger
Copy link
Copy Markdown
Collaborator

Thanks for the fixes!

Comment thread InfiniLink/Core/Components/Charts/Heart/HeartChartView.swift Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ui Improvements or changes to the user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants