"use client"; import { cn } from "@/lib/utils"; import { SankeyContext, type SankeyChartProps, useSankeyModel } from "./sankey-chart/context"; import { SankeyChartPlot } from "./sankey-chart/plot"; import { SankeyChartTooltip } from "./sankey-chart/tooltip"; /** * Weighted flows between nodes, laid out in columns from sources to outcomes. * Compose Plot and Tooltip, or omit children for the complete chart. * * ```tsx * * * * * ``` */ export function SankeyChart({ nodes, links, label, formatValue, colors, nodeWidth, nodePadding, activeId, defaultActiveId, onActiveChange, className, children, ...props }: SankeyChartProps) { const model = useSankeyModel({ nodes, links, label, formatValue, colors, nodeWidth, nodePadding, activeId, defaultActiveId, onActiveChange, }); return (
{children === undefined ? ( <> ) : ( children )}
{model.flows.map((flow) => ( ))}
{model.label} data
Flow Value Share of source
{flow.source} to {flow.target} {model.formatValue(flow.value)} {flow.share ? `${(flow.share * 100).toFixed(1)}%` : ""}
); } export { type SankeyActive, type SankeyChartProps, useSankeyChart, } from "./sankey-chart/context"; export type { PlacedLink as SankeyPlacedLink, PlacedNode as SankeyPlacedNode, SankeyLink, SankeyNode, } from "./sankey-chart/model"; export { SankeyChartPlot, type SankeyChartPlotProps } from "./sankey-chart/plot"; export { SankeyChartTooltip, type SankeyChartTooltipProps } from "./sankey-chart/tooltip";