Skip to content

refactor(metrics): Prevent chart crashes with empty data#4578

Merged
jamesarich merged 1 commit into
mainfrom
fix/chart-crash
Feb 17, 2026
Merged

refactor(metrics): Prevent chart crashes with empty data#4578
jamesarich merged 1 commit into
mainfrom
fix/chart-crash

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This commit introduces checks to prevent crashes in the metrics charts when there is no data to display. The charts will now only render if there is valid data available for at least one series.

This is achieved by pre-filtering the telemetry data and only creating chart layers and axes if the corresponding data is not empty. This improves the robustness of the metrics feature by gracefully handling cases where certain telemetry data might be missing.

Specific changes:

  • In PowerMetrics, DeviceMetrics, EnvironmentCharts, and SignalMetrics, data for each series is filtered and stored in remember blocks.
  • Chart layers (LineCartesianLayer) and axes (VerticalAxis) are conditionally created only if their corresponding data is not empty.
  • The GenericMetricChart composable is only called if there is at least one layer to render.
  • Added @Suppress("CyclomaticComplexMethod") to DeviceMetricsChart and SignalMetricsChart due to increased conditional complexity.
  • In PaxMetrics, chart data series are now memoized using remember.

This commit introduces checks to prevent crashes in the metrics charts when there is no data to display. The charts will now only render if there is valid data available for at least one series.

This is achieved by pre-filtering the telemetry data and only creating chart layers and axes if the corresponding data is not empty. This improves the robustness of the metrics feature by gracefully handling cases where certain telemetry data might be missing.

Specific changes:
- In `PowerMetrics`, `DeviceMetrics`, `EnvironmentCharts`, and `SignalMetrics`, data for each series is filtered and stored in `remember` blocks.
- Chart layers (`LineCartesianLayer`) and axes (`VerticalAxis`) are conditionally created only if their corresponding data is not empty.
- The `GenericMetricChart` composable is only called if there is at least one layer to render.
- Added `@Suppress("CyclomaticComplexMethod")` to `DeviceMetricsChart` and `SignalMetricsChart` due to increased conditional complexity.
- In `PaxMetrics`, chart data series are now memoized using `remember`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@github-actions github-actions Bot added the bugfix PR tag label Feb 17, 2026
@jamesarich jamesarich enabled auto-merge February 17, 2026 13:42
@codecov

codecov Bot commented Feb 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 14.79%. Comparing base (d374e76) to head (f81118f).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4578      +/-   ##
==========================================
- Coverage   14.79%   14.79%   -0.01%     
==========================================
  Files         428      429       +1     
  Lines       14845    14846       +1     
  Branches     2456     2457       +1     
==========================================
  Hits         2197     2197              
- Misses      12330    12331       +1     
  Partials      318      318              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit 85b3acd Feb 17, 2026
9 checks passed
@jamesarich jamesarich deleted the fix/chart-crash branch February 17, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant