Skip to content

docs: basic sankey example + profit sankey - #16

Merged
tannerlinsley merged 10 commits into
TanStack:mainfrom
gillkyle:codex/apple-income-sankey
Jul 31, 2026
Merged

docs: basic sankey example + profit sankey#16
tannerlinsley merged 10 commits into
TanStack:mainfrom
gillkyle:codex/apple-income-sankey

Conversation

@gillkyle

@gillkyle gillkyle commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Added a couple examples + conformance tests against Recharts like other examples had.

Not sure if these are as simple as they should be, so please hack away at them or re-implement them if this just serves as a decent reference.

These use a d3 plugin d3-sankey, so had to install that too


Case Geometry match Visual Types TanStack/Recharts source
Basic Sankey 99.9% Pass Clean 1.46×
Apple Sankey 95.8% Pass Clean 1.13×

Screenshots

Basic Profit
CleanShot 2026-07-31 at 10 15 52 CleanShot 2026-07-31 at 10 15 44

Summary by CodeRabbit

  • New Features
    • Added basic and income-statement Sankey chart examples with responsive layouts, labeled nodes, styled links, and accessible output.
    • Added deterministic flow revisions for exploring changing Sankey data while preserving flow totals.
  • Documentation
    • Added Sankey diagrams to the networks and hierarchies guide, including customization, labeling, styling, and data-conservation guidance.
  • Tests
    • Added conformance coverage for layout bounds, rendered elements, link validity, styling, ordering, and flow conservation.

@socket-security

socket-security Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​d3-sankey@​0.12.51001007481100
Addedd3-sankey@​0.12.310010010075100

View full report

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@tannerlinsley, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21afde7e-554e-4339-9458-b19c26283737

📥 Commits

Reviewing files that changed from the base of the PR and between 715b74f and c24a590.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (22)
  • .changeset/native-sankey-links.md
  • API-FRICTION.md
  • CHANGELOG.md
  • benchmarks/conformance/cases/111-basic-sankey/case.json
  • benchmarks/conformance/cases/111-basic-sankey/layout.ts
  • benchmarks/conformance/cases/111-basic-sankey/recharts.ts
  • benchmarks/conformance/cases/111-basic-sankey/tanstack.test.ts
  • benchmarks/conformance/cases/111-basic-sankey/tanstack.ts
  • benchmarks/conformance/cases/111-sankey-flow/case.json
  • benchmarks/conformance/cases/111-sankey-flow/layout.ts
  • benchmarks/conformance/cases/111-sankey-flow/model.ts
  • benchmarks/conformance/cases/111-sankey-flow/recharts.ts
  • benchmarks/conformance/cases/111-sankey-flow/tanstack.test.ts
  • benchmarks/conformance/cases/111-sankey-flow/tanstack.ts
  • docs/examples/networks-and-hierarchies.md
  • docs/reference/marks/rules-links-arrows-vectors-and-ticks.md
  • package.json
  • packages/charts-core/docs/examples/networks-and-hierarchies.md
  • packages/charts-core/docs/reference/marks/rules-links-arrows-vectors-and-ticks.md
  • packages/charts-core/src/link.test.ts
  • packages/charts-core/src/link.ts
  • scripts/catalog-definition-shapes.test.mjs
📝 Walkthrough

Walkthrough

Adds basic and Apple FY22 Sankey conformance cases for TanStack and Recharts. The changes include typed flow models, responsive renderers, validation tests, documentation, D3 Sankey packages, and catalog count updates.

Changes

Sankey conformance cases

Layer / File(s) Summary
Basic Sankey flow and renderers
benchmarks/conformance/cases/111-basic-sankey/*
Adds a four-node split-and-recombine dataset, TanStack and Recharts renderers, responsive layout logic, custom marks, validation, and conformance tests.
Income-statement Sankey flow
benchmarks/conformance/cases/111-sankey-flow/*
Adds the Apple FY22 income-statement model, deterministic revisions, responsive labeled renderers, endpoint and bounds validation, and flow-conservation tests.
Sankey documentation and registration
docs/examples/networks-and-hierarchies.md, packages/charts-core/docs/examples/networks-and-hierarchies.md, examples/conformance/package.json, package.json, scripts/catalog-artifact.mjs, scripts/catalog-definition-shapes.test.mjs
Documents Sankey usage, adds D3 Sankey packages, and updates catalog expectations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

Basic Sankey rendering flow

sequenceDiagram
  participant ConformanceInput
  participant basicSankeyData
  participant d3Sankey
  participant BasicSankeyRenderer
  ConformanceInput->>basicSankeyData: provide revision
  basicSankeyData->>d3Sankey: provide nodes and links
  d3Sankey->>BasicSankeyRenderer: return laid-out graph
  BasicSankeyRenderer->>ConformanceInput: return rendered scene nodes and chart points
Loading

Income-statement Sankey rendering flow

sequenceDiagram
  participant ConformanceInput
  participant incomeStatementData
  participant d3Sankey
  participant SankeyRenderer
  ConformanceInput->>incomeStatementData: provide revision
  incomeStatementData->>d3Sankey: provide income-statement nodes and links
  d3Sankey->>SankeyRenderer: return resolved endpoints and layout bounds
  SankeyRenderer->>ConformanceInput: return rendered links, nodes, labels, values, and chart points
Loading

Possibly related PRs

  • TanStack/charts#2: Updates catalog implementation counts used by the artifact publication tooling.

Suggested reviewers: tannerlinsley

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two Sankey examples added by the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
benchmarks/conformance/cases/111-basic-sankey/tanstack.ts (1)

20-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate responsiveLayout/clamp helpers across renderers.

Lines 136-149 (responsiveLayout, clamp) are byte-for-byte identical to the same functions in recharts.ts (lines 100-113). Consider extracting them to a shared module (for example model.ts or a small layout.ts alongside it) so both renderers stay in sync when layout tuning changes. This duplication may be intentional to keep each conformance renderer self-contained for side-by-side comparison, so treat this as optional.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmarks/conformance/cases/111-basic-sankey/tanstack.ts` around lines 20 -
134, Optionally extract the shared responsiveLayout and clamp helpers used by
basicSankey and the corresponding recharts renderer into a common layout or
model module, then update both renderers to import and reuse them so layout
tuning remains synchronized while preserving current behavior.
benchmarks/conformance/cases/111-sankey-flow/recharts.ts (1)

115-136: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Render the title outside the node renderer.

The title is emitted only when index === 0, so it depends on Recharts calling the node renderer for the first data node and on that group not being clipped or reordered. Render the title as a sibling of Sankey inside a wrapping element, or through a Recharts label component. This also removes the hidden coupling to node order.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmarks/conformance/cases/111-sankey-flow/recharts.ts` around lines 115 -
136, The title rendering currently depends on the first node invocation in the
renderer. Move the incomeStatementTitle element out of the index === 0 branch in
the node renderer and render it as a sibling of Sankey within a wrapping
element, or via a Recharts label component, while preserving its existing
positioning and styling.
benchmarks/conformance/cases/111-sankey-flow/tanstack.ts (1)

208-250: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider sharing the layout helpers with the Recharts implementation.

responsiveLayout, clamp, and labelBackdropBounds are identical to benchmarks/conformance/cases/111-sankey-flow/recharts.ts lines 167-209. Both renderers must stay pixel-comparable for the conformance comparison. If one copy changes, the case silently loses parity. Move the three helpers into a shared module in the case directory, for example layout.ts, and import them from both files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmarks/conformance/cases/111-sankey-flow/tanstack.ts` around lines 208 -
250, Move responsiveLayout, clamp, and labelBackdropBounds into a shared layout
module in the sankey-flow case directory, then remove their local definitions
and import the shared helpers from both tanstack.ts and recharts.ts. Preserve
the existing helper behavior and signatures so both renderers remain
pixel-comparable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benchmarks/conformance/cases/111-sankey-flow/model.ts`:
- Around line 143-150: Update the depth-0 node ordering in the Sankey case so
services has a unique order value that matches its intended position after
wearables. Move the services template into that corresponding position in the
node array and remove its existing later duplicate, preserving the other nodes’
relative order.

In `@benchmarks/conformance/cases/111-sankey-flow/recharts.ts`:
- Line 11: Update the Sankey type import to use Recharts’ public renamed
typings, SankeyNodeProps and SankeyLinkProps, instead of the internal Sankey
NodeProps and LinkProps exports. Apply the renamed types to the node/link render
callbacks, or define equivalent local prop interfaces if the public types are
unavailable.

---

Nitpick comments:
In `@benchmarks/conformance/cases/111-basic-sankey/tanstack.ts`:
- Around line 20-134: Optionally extract the shared responsiveLayout and clamp
helpers used by basicSankey and the corresponding recharts renderer into a
common layout or model module, then update both renderers to import and reuse
them so layout tuning remains synchronized while preserving current behavior.

In `@benchmarks/conformance/cases/111-sankey-flow/recharts.ts`:
- Around line 115-136: The title rendering currently depends on the first node
invocation in the renderer. Move the incomeStatementTitle element out of the
index === 0 branch in the node renderer and render it as a sibling of Sankey
within a wrapping element, or via a Recharts label component, while preserving
its existing positioning and styling.

In `@benchmarks/conformance/cases/111-sankey-flow/tanstack.ts`:
- Around line 208-250: Move responsiveLayout, clamp, and labelBackdropBounds
into a shared layout module in the sankey-flow case directory, then remove their
local definitions and import the shared helpers from both tanstack.ts and
recharts.ts. Preserve the existing helper behavior and signatures so both
renderers remain pixel-comparable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 53809767-7cad-4011-91f6-4f029e20f03f

📥 Commits

Reviewing files that changed from the base of the PR and between 8437114 and e73fcc2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • benchmarks/conformance/cases/111-basic-sankey/case.json
  • benchmarks/conformance/cases/111-basic-sankey/model.ts
  • benchmarks/conformance/cases/111-basic-sankey/recharts.ts
  • benchmarks/conformance/cases/111-basic-sankey/tanstack.test.ts
  • benchmarks/conformance/cases/111-basic-sankey/tanstack.ts
  • benchmarks/conformance/cases/111-sankey-flow/case.json
  • benchmarks/conformance/cases/111-sankey-flow/model.ts
  • benchmarks/conformance/cases/111-sankey-flow/recharts.ts
  • benchmarks/conformance/cases/111-sankey-flow/tanstack.test.ts
  • benchmarks/conformance/cases/111-sankey-flow/tanstack.ts
  • docs/examples/networks-and-hierarchies.md
  • examples/conformance/package.json
  • package.json
  • packages/charts-core/docs/examples/networks-and-hierarchies.md
  • scripts/catalog-artifact.mjs

Comment thread benchmarks/conformance/cases/111-sankey-flow/model.ts
Comment thread benchmarks/conformance/cases/111-sankey-flow/recharts.ts Outdated
@tannerlinsley
tannerlinsley merged commit d2fd700 into TanStack:main Jul 31, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 31, 2026
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.

2 participants