Repository navigation
feat(Treemap): Add selected prop to zoom into a node without distorting tiles or padding - #1017
Merged
Merged
Conversation
…ting tiles or padding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 331c4d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Contributor
Preview deploymenthttps://pr-1017-layerchart.techniq.workers.dev Built from 331c4d8. |
Contributor
Bundle Size Analysis
|
| Item | Current | New | Change |
|---|---|---|---|
🔴 Treemap |
7.50 KB 2.66 gz |
8.10 KB 2.87 gz |
+0.60 KB (+7.9%) +0.21 gz (+8.0%) |
Use-Case Scenarios
Hierarchy (1 changed)
| Scenario | Current | New | Change |
|---|---|---|---|
🟡 hierarchy-treemap |
356.27 KB 83.88 gz |
356.87 KB 84.08 gz |
+0.61 KB (+0.2%) +0.20 gz (+0.2%) |
Graph / network (1 changed)
| Scenario | Current | New | Change |
|---|---|---|---|
🟡 sankey |
361.59 KB 84.87 gz |
359.72 KB 84.53 gz |
-1.87 KB (-0.5%) -0.33 gz (-0.4%) |
Components (2 changed)
| Scenario | Current | New | Change |
|---|---|---|---|
🟢 Sankey |
9.65 KB 2.94 gz |
8.29 KB 2.69 gz |
-1.35 KB (-14.0%) -0.25 gz (-8.6%) |
🔴 Treemap |
7.50 KB 2.66 gz |
8.10 KB 2.87 gz |
+0.60 KB (+7.9%) +0.21 gz (+8.0%) |
Worst case (1 changed)
| Scenario | Current | New | Change |
|---|---|---|---|
🟡 all |
1108.18 KB 263.55 gz |
1103.60 KB 262.33 gz |
-4.58 KB (-0.4%) -1.22 gz (-0.5%) |
Understanding this report
- Use-case scenarios measure the bundle cost of common chart configurations (e.g. a line chart with axes)
- Individual components measure each component imported in isolation
- Svelte runtime is excluded; sizes reflect layerchart + its dependencies (d3, etc.)
- When multiple components share dependencies (e.g. d3-scale), the real-world cost is lower than the sum of individual sizes
- Changes smaller than 10 bytes or 0.1% are considered insignificant
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zooming the Treemap nested zoom example distorts the tiles and blows up the padding.
Why
The treemap was tiled once at full size, then
Boundsstretched the selected node to fill the chart. The stretch differs in x and y, so squarified tiles lose their shape, and padding (layout pixels) is scaled with it: the 20px headers became ~70px and the 4px gaps ~16px.Fix
Treemapgets aselectedprop (matched bydata):The nested-zoom example drops
Boundsand passes{selected}. It animates with the existingmotionprops onGroup,RectandRectClipPath, with the nodes keyed bydata, so each node tweens from its old rectangle to its new one.Tradeoff
With
squarify, the arrangement of tiles at the zoomed size can differ from the overview, so siblings can briefly slide across each other during the 800ms tween. They always stay inside their parents. With Maintain Aspect Ratio on, the arrangement is unchanged and the transition is a clean scale.Comparison
Before
CleanShot.2026-11-22.at.12.26.20.AM.mp4
After
CleanShot.2026-11-22.at.12.27.04.AM.mp4
🤖 Generated with Claude Code