Skip to content

Use brightest color for checkerboard when only one is available - #47129

Merged
sgress454 merged 2 commits into
mainfrom
sgress454/bias-charts-towards-lighter-colors
Jun 8, 2026
Merged

Use brightest color for checkerboard when only one is available#47129
sgress454 merged 2 commits into
mainfrom
sgress454/bias-charts-towards-lighter-colors

Conversation

@sgress454

@sgress454 sgress454 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #47128

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
    n/a, unreleased

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually
    on main:
Image

on branch:
image

For unreleased bug fixes in a release candidate, one of:

  • Confirmed that the fix is not expected to adversely impact load test results

Summary by CodeRabbit

  • Bug Fixes
    • Fixed checkerboard visualization color scaling to properly render non-zero data cells at the brightest color level when all non-zero values are identical.

@sgress454
sgress454 requested a review from a team as a code owner June 8, 2026 19:58
Copilot AI review requested due to automatic review settings June 8, 2026 19:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Dashboard checkerboard relative scaling so that when all non-zero cells share the same value (min === max), they render at the brightest color level instead of collapsing to the dimmest level. This aligns the UI with the expected behavior in #47128 for charts like “Hosts online” when filtered down to a single host.

Changes:

  • Update relative-scale color-level calculation to return level 5 when the non-zero range is 0.
  • Add a regression test covering the single-distinct-value relative-scale case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frontend/pages/DashboardPage/cards/ChartCard/CheckerboardViz.tsx Adjusts relative-scale color selection to use brightest level when min/max are equal.
frontend/pages/DashboardPage/cards/ChartCard/CheckerboardViz.tests.tsx Adds automated coverage to prevent regressions when relativeScale has only one distinct non-zero value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.17%. Comparing base (b23f808) to head (88a798a).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #47129    +/-   ##
========================================
  Coverage   67.17%   67.17%            
========================================
  Files        2908     2911     +3     
  Lines      226136   226147    +11     
  Branches    11829    11683   -146     
========================================
+ Hits       151898   151906     +8     
- Misses      60508    60512     +4     
+ Partials    13730    13729     -1     
Flag Coverage Δ
frontend 57.65% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 518ebc82-f97f-43f6-b2af-6d029f7779d6

📥 Commits

Reviewing files that changed from the base of the PR and between 2bf5106 and 88a798a.

📒 Files selected for processing (2)
  • frontend/pages/DashboardPage/cards/ChartCard/CheckerboardViz.tests.tsx
  • frontend/pages/DashboardPage/cards/ChartCard/CheckerboardViz.tsx

Walkthrough

This PR fixes a bug in the CheckerboardViz component where cells with uniform non-zero values were rendered in the dimmest color instead of the brightest. The implementation removes a divide-by-zero workaround (|| 1) and adds an explicit check: when all non-zero values are identical (range = 0), all non-zero cells map to level 5 (brightest). A new test validates this behavior by verifying that zero cells remain at level 0 while all non-zero cells reach level 5 when the dataset contains only one distinct non-zero value.

Possibly related PRs

  • fleetdm/fleet#45791: Both PRs modify relativeScale color-level logic in CheckerboardViz.tsx and update corresponding tests for non-zero cell coloring.
  • fleetdm/fleet#44959: Both PRs adjust relativeScale min/max/ramp level computation for non-zero cells in CheckerboardViz.tsx with aligned test updates.
  • fleetdm/fleet#45300: Modifies CSS color values for --level-1--level-5 buckets in the red theme, directly connecting to the level-mapping behavior changed in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: using the brightest color for checkerboard visualization when only one color is available, which directly addresses the linked issue.
Description check ✅ Passed The PR description includes the related issue reference (#47128), completed testing checklist items with evidence (automated tests and screenshots), and status confirmation for load testing concerns.
Linked Issues check ✅ Passed The code changes directly address issue #47128 by implementing logic to use the brightest color when all non-zero checkerboard values are identical, with unit tests verifying this behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to the CheckerboardViz component (implementation and tests) and directly support the fix for the reported issue; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sgress454/bias-charts-towards-lighter-colors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sgress454
sgress454 merged commit 3cd8e11 into main Jun 8, 2026
25 checks passed
@sgress454
sgress454 deleted the sgress454/bias-charts-towards-lighter-colors branch June 8, 2026 20:21
sgress454 added a commit that referenced this pull request Jun 8, 2026
…e is available (#47133)

Cherry-pick of #47129 into the rc-minor-fleet-v4.87.0 RC branch.
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.

When checkerboard has only one color, dimmest color is used

3 participants