Skip to content

Clamp BG graph to HIGH/LOW display range#600

Open
bjorkert wants to merge 1 commit intodevfrom
clamp_graph_to_display_range
Open

Clamp BG graph to HIGH/LOW display range#600
bjorkert wants to merge 1 commit intodevfrom
clamp_graph_to_display_range

Conversation

@bjorkert
Copy link
Copy Markdown
Contributor

Summary

When a Nightscout reading exceeds maxDisplayGlucose (400 mg/dL), the main header correctly shows HIGH but the chart plots the raw value (e.g. 550) and autoscales the y-axis up to 600. This makes the chart inconsistent with the header text.

This PR clamps the plotted y-value in updateBGGraph to [minDisplayGlucose, maxDisplayGlucose] (39–400 mg/dL) so the chart line stays within the range the header represents. The pill tooltip still shows the raw reading so the exact value is accessible on tap.

  • Chart-only change — bgData, stats, alarms, and color coding are unaffected.
  • Predictions were already clamped to these bounds upstream (DeviceStatusLoop, DeviceStatusOpenAPS), so the graph is now consistent across both data types.
  • Updated the Globals.swift comment to reflect the broader usage of the constants.

When a Nightscout reading exceeds maxDisplayGlucose (400 mg/dL), the
main display correctly shows "HIGH" but the chart was plotting the raw
value (e.g. 550) and autoscaling the y-axis up to 600. This makes the
chart inconsistent with the header.

Clamp the plotted y-value in updateBGGraph to [minDisplayGlucose,
maxDisplayGlucose] so the chart line stays within the same range
the display text represents. The pill tooltip still shows the raw
reading so the exact value is accessible on tap.
@bjorkert bjorkert requested a review from marionbarker April 10, 2026 08:22
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