桑基图表卡
仪表盘卡外壳中的 Sankey 流程。 Recharts 列出节点和链接;该卡在图表变量中绘制胶囊节点,用其源的颜色为每个功能区着色,以便每个源的流读取为一个系列,在左侧用名称和值标记源,在右侧用其份额标记源,并隔离您悬停的任何内容(节点或链接),而标题如下。
Tracked time
86h
Tracked timeShare of tracked time
使用共享 UI 包或自定义导入别名? 配置您的安装路径 在运行 CLI 之前。复制粘贴示例使用默认导入。
数据
nodes 是一个 { name, color? } 列出和 links 是 { source, target, value },通过名称或索引引用节点。节点值、标题总数、接收份额和悬停关系都源自链接。当您通过时,经期药会出现在下拉列表中 ranges - 每个范围都有自己的数据(并且可选 delta / headline) 并且图表在选择时重新显示动画; onRangeChange 让你取而代之。在没有数据属性的情况下,该卡提供了三个演示范围,这就是上面的预览所使用的。
// Sources carry the colour - every ribbon leaving a node takes that node's// colour (linkColor="source", the default) - and sinks stay "neutral" so the// ribbons paint them. Nodes without a colour cycle the palette by index.const nodes = [ { name: "Focus", color: "var(--color-chart-7)" }, { name: "Meetings", color: "var(--color-chart-5)" }, { name: "Browsing", color: "neutral" }, { name: "Writing", color: "neutral" }, { name: "Email", color: "neutral" },];
// Links reference nodes by name (or index). Add a node + link and the// layout rebalances; the right-hand percentages are shares of all sinks.const links = [ { source: "Focus", target: "Browsing", value: 16.2 }, { source: "Focus", target: "Writing", value: 11.6 }, { source: "Focus", target: "Email", value: 3.4 }, { source: "Meetings", target: "Email", value: 1.2 },];
<SankeyChartCard title="Tracked time" nodes={nodes} links={links} format={(n) => `${n}h`} // headline + source labels range="This week" // static pill… axisLabels={["Tracked time", "Share of tracked time"]}/>
// …or a working period dropdown: each range overrides links (and nodes / delta / headline).<SankeyChartCard nodes={nodes} ranges={[ { id: "this-week", label: "This week", links: thisWeek }, { id: "last-week", label: "Last week", links: lastWeek }, { id: "this-month", label: "This month", links: thisMonth }, ]}/>