Skip to content

Fix [DEV-12185] Improve waffle rounding#2704

Merged
jayb merged 2 commits intodevfrom
waffle-rounding
Apr 8, 2026
Merged

Fix [DEV-12185] Improve waffle rounding#2704
jayb merged 2 commits intodevfrom
waffle-rounding

Conversation

@jayb
Copy link
Copy Markdown
Collaborator

@jayb jayb commented Apr 8, 2026

Summary

Improves waffle rounding in dynamic-denominator mode when denominator is fractional.

@jayb jayb requested a review from adamdoe as a code owner April 8, 2026 13:31
Copilot AI review requested due to automatic review settings April 8, 2026 13:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves how the waffle chart computes filled nodes in dynamic-denominator mode when the denominator is fractional, aligning the filled-dot rounding with the raw numerator/denominator ratio and adding coverage for key edge cases.

Changes:

  • Update dynamic-denominator fill calculation to round based on (numerator / denominator) * roundedDenominator, with clamping.
  • Ensure dynamic-denominator mode is only used when numerator <= denominator, otherwise fall back to the fixed 100-node mode.
  • Add/adjust unit tests and Storybook editor assertions for fractional denominator rounding behavior.

Reviewed changes

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

File Description
packages/waffle-chart/src/CdcWaffleChart.tsx Adjusts dynamic-denominator eligibility and computes filled nodes via raw ratio-based rounding with clamping.
packages/waffle-chart/src/test/CdcWaffleChart.test.jsx Adds tests verifying ratio-based rounding, text preservation, and fallback when numerator exceeds denominator.
packages/waffle-chart/src/_stories/WaffleChart.Editor.stories.tsx Updates editor test expectations to match the new rounding behavior (e.g., 17/20 instead of 18/20).

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

@jayb jayb merged commit 52f1a12 into dev Apr 8, 2026
3 checks passed
@jayb jayb deleted the waffle-rounding branch April 8, 2026 15:15
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.

3 participants