Skip to content

Sankey mark s2 - #896

Open
tanugarg04 wants to merge 2 commits into
mainfrom
sankey-mark-s2
Open

Sankey mark s2#896
tanugarg04 wants to merge 2 commits into
mainfrom
sankey-mark-s2

Conversation

@tanugarg04

@tanugarg04 tanugarg04 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds a Sankey/Flow mark to React Spectrum Charts S2 (vega-spec-builder-s2 + react-spectrum-charts-s2), following the same conventions as Donut/Venn rather than the unimplemented pre-alpha spec (planning/specs/pre-alpha/sankey/add-sankey-mark.json), which this PR intentionally departs from based on the research in planning/research/sankey-workspace-flow-feasibility/.

Description

  • Layout (vega-spec-builder-s2/src/sankey/sankeyUtils.ts): topological column assignment with cycle detection (back edges are dropped from layering, still rendered, and reported via console.warn), value-proportional node/link sizing, iterative left-right/right-left relaxation to reduce ribbon crossings, and a cubic-bezier ribbon path generator.
  • Spec builder (sankeySpecBuilder.ts): addSankey/addData/addMarks/addScales/addSignals, wired into chartSpecBuilder.ts the same way every other mark is.
  • React layer: a pre-alpha/components/Sankey component, sankeyAdapter.ts, and the usual children-adapter/utils.ts allow-list wiring — mirrors Donut exactly.
  • Interactivity: ChartInspect/ChartPopover (click-to-pin and right-click) work on both the node and link layers out of the box, reusing the same generic, mark-agnostic plumbing every other mark already has — no sankey-specific code was needed for this.
  • Labels: node name/value labels reuse Line's direct-label halo technique (background + foreground text pair) and the shared getDirectLabelFontSizeProductionRule font-size mechanism, rather than a bespoke sizing signal.
  • Stories: Basic, TwoColumnFlow, SingleChain, ThreeColumnFlow, NodeAndLinkInspect, RightClickInspect, and WorkspaceFlowExample (approximates Analysis Workspace's own Flow visualization: root node, comma-formatted counts, "+N more" long-tail nodes, s2Categorical16 palette).

Related Issue

Motivation and Context

How Has This Been Tested?

  • New unit tests for the layout algorithm (column assignment incl. cycles, node/link sizing, ribbon geometry) and the spec builder (addData/addMarks/addScales/addSignals).
  • End-to-end jsdom tests rendering through real Vega for every story, including a right-click regression test on both node and link marks.
  • Full vega-spec-builder-s2 + react-spectrum-charts-s2 suites pass (2139/2139); tsc --noEmit clean on both packages (no new errors vs. baseline); eslint clean.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Ports the layout math from Workspace's own production d3.pathing()
algorithm (CloudViz.js), rewritten dependency-free, into a new
vega-spec-builder-s2/sankey module: topological column assignment
(with cycle detection), value-proportional node/link sizing, iterative
crossing-reduction relaxation, and variable-width bezier ribbon paths.

Wires it into react-spectrum-charts-s2 following the Donut/Venn
conventions: a pre-alpha/components/Sankey React component, an
rscToSbAdapter, and children-adapter/utils wiring for chartInspects
and chartPopovers (including right-click support, which required no
mark-specific code since that plumbing is already generic across all
marks).

Node/value labels reuse Line's direct-label halo technique
(background + foreground text pair) and the shared
getDirectLabelFontSizeProductionRule mechanism rather than a bespoke
font-size signal. Includes Storybook stories approximating Analysis
Workspace's own Flow visualization, plus unit and end-to-end tests.

Also saves the research doc that grounded the design decisions
(planning/research/sankey-workspace-flow-feasibility.md).
- Fix duplicate ./sankeyTestUtils import in sankeyUtils.test.ts (lint error)
- Remove vestigial, never-read SankeySpecOptions.backgroundColor field
- Harden getSankeyEdges to drop negative/NaN/non-finite values, with a test
- Shorten and tighten explanatory comments across the sankey module
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.

1 participant