Skip to content

Fix ForecastView rendering past forecast points#1092

Open
k9track wants to merge 1 commit intonightscout:devfrom
k9track:fix/forecastview-filter-past-points
Open

Fix ForecastView rendering past forecast points#1092
k9track wants to merge 1 commit intonightscout:devfrom
k9track:fix/forecastview-filter-past-points

Conversation

@k9track
Copy link
Copy Markdown

@k9track k9track commented Apr 7, 2026

Summary

  • ForecastView's AreaMark and LineMark were rendering for timestamps in the past, causing visual artifacts on the glucose chart
  • Added a lower bound check (xValue >= Date()) to all three render locations so forecast marks only render for future timestamps
  • The existing upper bound check (xValue <= Date(timeIntervalSinceNow: TimeInterval(hours: 2.5))) was already in place — this adds the missing lower bound

Changes

File: Trio/Sources/Modules/Home/View/Chart/ChartElements/ForecastView.swift

Three identical changes at lines 44, 60, and 83:

// Before
if xValue <= Date(timeIntervalSinceNow: TimeInterval(hours: 2.5)) {

// After
if xValue >= Date(), xValue <= Date(timeIntervalSinceNow: TimeInterval(hours: 2.5)) {

Test plan

  • Verify forecast cone only renders for future timestamps on the glucose chart
  • Confirm no visual artifacts from past forecast data points
  • Check that the 2.5-hour upper bound still works correctly

The AreaMark and LineMark in ForecastView were rendering for timestamps
in the past, causing visual artifacts on the glucose chart. Added a
lower bound check (xValue >= Date()) so forecast marks only render for
future timestamps, matching the existing upper bound of 2.5 hours.
@dnzxy
Copy link
Copy Markdown
Contributor

dnzxy commented Apr 7, 2026

Do you have an example or an associated issue report for such artifacts and faulty renderings?

Edit: reason I am asking this is that a forecasted cone that begins in the past is actually intended behavior if the last loop cycle in fact in the past, or the map even have skipped a loop or two. So just trying to identify what issue you are seeing because from a brief overview of the proposed changes it looks like this is breaking intentional behavior.

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.

2 participants