fix: PieChart double padding gap when a data item has value 0#7113
fix: PieChart double padding gap when a data item has value 0#7113PavelVanecek merged 5 commits intomainfrom
Conversation
Co-authored-by: PavelVanecek <1100170+PavelVanecek@users.noreply.github.com>
PavelVanecek
left a comment
There was a problem hiding this comment.
Perfect, the test reproduces this well. Now please investigate the problem and fix it
Co-authored-by: PavelVanecek <1100170+PavelVanecek@users.noreply.github.com>
Co-authored-by: PavelVanecek <1100170+PavelVanecek@users.noreply.github.com>
The bug is in Fix (commit |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7113 +/- ##
=======================================
Coverage 89.61% 89.61%
=======================================
Files 534 534
Lines 40294 40294
Branches 5490 5491 +1
=======================================
Hits 36109 36109
Misses 4177 4177
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 56 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-umdAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-treeshaking-polarAssets Changed:
view changes for bundle: recharts/bundle-es6Assets Changed:
|
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |

Description
Fixes the double-padding bug in
Piecharts where a zero-value data item combined with a non-zeropaddingAnglecauses a visibly larger gap between the adjacent non-zero sectors.Root cause:
computePieSectorswas storingpaddingAngle: 5on zero-value sectors (same as non-zero ones). TheSectorsWithAnimationrendering code reconstructs sector positions from scratch using each sector's storedpaddingAngleas a cursor offset. Since a zero-value sector hadpaddingAngle: 5, the cursor advanced by 5° for the invisible sector, and then the next visible sector added another 5°, producing a 10° double gap instead of the expected 5°.Fix: Zero-value sectors now store
paddingAngle: 0incomputePieSectors, so the animation code does not advance the cursor for them.Changes:
src/polar/Pie.tsx— setpaddingAngle: 0for zero-value sectors incomputePieSectorstest/state/selectors/pieSelectors.spec.tsx— unit test verifying zero-value sectors havepaddingAngle: 0test-vr/tests/PieChart.spec-vr.tsx— VR test with data containing avalue: 0entry andpaddingAngle={5}Related Issue
Double padding on
PieChartWithPaddingAnglewhen value is0.Motivation and Context
When
paddingAngleis set and a data item hasvalue: 0, the gap between the two non-zero sectors surrounding the zero-value sector appears twice as wide as all other gaps. This is because the animation rendering code uses the storedpaddingAnglefield on each sector to re-derive positions, and a zero-value sector was incorrectly storing a non-zeropaddingAngle, consuming extra space even though the sector itself has zero width.How Has This Been Tested?
test/state/selectors/pieSelectors.spec.tsxdirectly assertspaddingAngle === 0for zero-value sectors andpaddingAngle === 5for non-zero sectors--update-snapshotsto regenerate the baseline; updated snapshot shows all three visible segments separated by equal 5° gapsScreenshots (if appropriate):
Three segments (400/300/200) with equal spacing — the gap where the zero-value segment sits is now the same width as all other gaps.
Types of changes
Checklist:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.