Add verticalAlign prop for Sankey#6576
Conversation
WalkthroughAdds a Changes
Sequence Diagram(s)sequenceDiagram
participant Sankey as Sankey Component
participant computeData
participant updateYOfTree
participant Relax as Relaxation Loop
Sankey->>computeData: computeData(data, ..., verticalAlign)
computeData->>updateYOfTree: updateYOfTree(depthTree, ..., verticalAlign)
alt verticalAlign == "justify"
updateYOfTree->>updateYOfTree: distribute nodes evenly within depth
computeData->>Relax: perform iterative relaxation passes (R->L, L->R)
Relax->>Relax: adjust node y positions and link offsets
else verticalAlign == "top"
updateYOfTree->>updateYOfTree: stack nodes from top using currentY progression
Note right of Relax: relaxation loop skipped
end
computeData-->>Sankey: return positioned nodes and links
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related issues
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)src/**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)src/chart/Sankey.tsx (1)
🔇 Additional comments (6)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test-vr/tests/SankeyChart.spec-vr.tsx (1)
39-55: LGTM! Good test coverage for the new prop.The visual regression tests follow the existing pattern and cover both values ('justify' and 'top') of the new
verticalAlignprop. The tests will effectively catch any visual regressions in the layout behavior.Optional enhancement: Consider adding combination tests that exercise both
alignandverticalAligntogether (e.g.,align="left" verticalAlign="top") to ensure the props interact correctly. This would provide more comprehensive coverage but can be deferred if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
test-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-justify-1-chromium-linux.pngis excluded by!**/*.pngtest-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-justify-1-firefox-linux.pngis excluded by!**/*.pngtest-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-justify-1-webkit-linux.pngis excluded by!**/*.pngtest-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-top-1-chromium-linux.pngis excluded by!**/*.pngtest-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-top-1-firefox-linux.pngis excluded by!**/*.pngtest-vr/__snapshots__/tests/SankeyChart.spec-vr.tsx-snapshots/Sankey-verticalAlign-top-1-webkit-linux.pngis excluded by!**/*.png
📒 Files selected for processing (2)
test-vr/tests/SankeyChart.spec-vr.tsx(1 hunks)www/src/docs/api/Sankey.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
www/**
📄 CodeRabbit inference engine (DEVELOPING.md)
Use the www directory to add and commit examples for the documentation website (recharts.github.io)
Files:
www/src/docs/api/Sankey.ts
🧠 Learnings (4)
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : Mock getBoundingClientRect using test/helper/MockGetBoundingClientRect.ts when rendering Recharts components (e.g., Tooltip, Legend, charts)
Applied to files:
test-vr/tests/SankeyChart.spec-vr.tsx
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : When testing selectors, verify render counts using the spy and rerenderSameComponent from createSelectorTestCase
Applied to files:
test-vr/tests/SankeyChart.spec-vr.tsx
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : In tests not using createSelectorTestCase, advance timers after renders with vi.runOnlyPendingTimers()
Applied to files:
test-vr/tests/SankeyChart.spec-vr.tsx
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Write unit tests using Vitest and React Testing Library
Applied to files:
test-vr/tests/SankeyChart.spec-vr.tsx
🧬 Code graph analysis (1)
test-vr/tests/SankeyChart.spec-vr.tsx (1)
src/chart/Sankey.tsx (1)
Sankey(976-1019)
🔇 Additional comments (1)
www/src/docs/api/Sankey.ts (1)
234-243: LGTM! Clear and comprehensive documentation.The documentation for the new
verticalAlignprop is well-written, follows the existing pattern, and clearly explains the behavior of both 'justify' and 'top' options.
src/chart/Sankey.tsx
Outdated
| modifiedNodes: newModifiedNodes, | ||
| }; | ||
| }, [data, width, height, margin, iterations, nodeWidth, nodePadding, sort, link, node, linkCurvature, align]); | ||
| }, [data, width, height, margin, iterations, nodeWidth, nodePadding, sort, link, node, linkCurvature, align, verticalAlign]); |
There was a problem hiding this comment.
looks like prettier needs to format this but otherwise LGTM. Thank you
|
@PavelVanecek @ckifer Just fixed the prettier issue, thanks |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6576 +/- ##
==========================================
- Coverage 91.18% 91.17% -0.01%
==========================================
Files 492 492
Lines 40999 41041 +42
Branches 4584 4585 +1
==========================================
+ Hits 37384 37419 +35
- Misses 3598 3605 +7
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 517 bytes (0.02%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-cjsAssets Changed:
|
Description
Adding support for top vertical alignment of nodes in Sankey
Related Issue
#6575
Motivation and Context
It's helpful in some use cases like in representing sequential processes like user journeys to be able to have nodes "stick" to the top so that the vertical position follows the natural reading order.
How Has This Been Tested?
Storybook
Screenshots (if appropriate):
verticalAlign

justifyverticalAlign

topTypes of changes
Checklist:
Summary by CodeRabbit