fix(storybook): use flat dataset for Simple and WithTooltip Treemap stories (#6364)#7072
Conversation
…tories Fix overlapping labels in Treemap storybook examples (fixes recharts#6364). The 'Simple' and 'With tooltip' stories were using sizeData, a nested hierarchical dataset with children arrays. Since Treemap defaults to type='flat', it rendered rectangles at every depth level, causing parent and child labels to overlap. Changes: - Add flatTreemapData: a flat dataset (no children nesting) for use with the default type='flat' rendering mode - Update Simple and WithTooltip stories to use flatTreemapData - Add a new Nested story that correctly demonstrates sizeData with type='nest' mode
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
WalkthroughThe changes address broken labels in treemap storybook examples by introducing a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7072 +/- ##
=======================================
Coverage 90.20% 90.20%
=======================================
Files 526 526
Lines 39650 39650
Branches 5442 5441 -1
=======================================
Hits 35768 35768
Misses 3873 3873
Partials 9 9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes #6364
The Simple and With tooltip Treemap storybook examples had overlapping/broken labels.
Root Cause
Both stories used
sizeData, a nested/hierarchical dataset (withchildrenarrays). Since the Treemap defaults totype="flat", it renders rectangles at every depth level — parents and children occupy overlapping space. The defaultContentItemrenderer draws a label on every node where the name fits, regardless of depth, causing all labels to pile on top of each other.The Custom story didn't have this problem because its custom
contentfunction only renders labels atdepth === 1.Changes
flatTreemapDatainstorybook/stories/data/Size.ts— a flat dataset (nochildrennesting) that works correctly withtype="flat"SimpleandWithTooltipstories to useflatTreemapDatainstead ofsizeDataNestedstory that properly demonstrates hierarchical data withtype="nest"modeVerification
Summary by CodeRabbit
Documentation
Chores