Sankey
Sankey is a self-contained flow diagram that visualizes how quantities split, merge,
and flow between stages. Nodes (rectangles) are connected by value-weighted ribbons,
conveying the magnitude and direction of each flow. It is not placed inside another chart
container.
import { Sankey, ResponsiveContainer, Tooltip } from "solid-recharts";
const data = {
nodes: [{ name: "A" }, { name: "B" }, { name: "C" }],
links: [
{ source: 0, target: 1, value: 100 },
{ source: 1, target: 2, value: 80 },
],
};
<ResponsiveContainer width="100%" height="100%">
<Sankey data={data}>
<Tooltip />
</Sankey>
</ResponsiveContainer>;
Loading source...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | { nodes, links } | — | Nodes array + links array (source/target indices) |
width, height | number | "%" | — | Fixed size or percentage inside ResponsiveContainer |
margin | { top, right, ...} | { 5, 5, 5, 5 } | Space around the plot area |
nodeWidth | number | 10 | Width of each node rectangle (in pixels) |
nodePadding | number | 10 | Vertical space between nodes at the same depth |
linkCurvature | number | 0.5 | Bezier curve tension (0 = straight, 1 = max curve) |
align | "left" | "justify" | "justify" | Horizontal alignment of nodes |
verticalAlign | "top" | "justify" | "justify" | Vertical alignment within columns |
All other recharts Sankey props are supported; see the
recharts Sankey docs for the full matrix.
Notes
- Data shape:
nodesis an array of{ name, ... }objects.linksis an array of{ source, target, value }wheresourceandtargetare node array indices. - Node names: The
nameKeyprop (default:"name") reads the node label from the node object. - Link width: Each ribbon's thickness is proportional to its
value. - Tooltip: Sankey supports item-type tooltips on nodes and links. Hovering a node or link displays its details, including the flow value.
- Custom renderers: Use the
nodeandlinkprops (function form) to render custom node/link graphics instead of the defaults. - Handlers:
onMouseEnter,onMouseLeave, andonClickreceive the item (NodePropsorLinkProps) and element type ("node"or"link").
See also
- ResponsiveContainer — fluid sizing
- Tooltip — hover info