echarts-sankey-chart
evilcharts/echarts-sankey-chartFreeComponent
Sankey chart component rendered with Apache ECharts
Install it
npx shadcn@latest add https://evilcharts.com/r/echarts-sankey-chart.jsonSource
1"use client";23import {4 resolveTooltipPosition,5 roundnessClass,6 tooltipIndicatorHtml,7 tooltipRow,8 tooltipVariantClass,9 type TooltipPosition,10 type TooltipRoundness,11 type TooltipVariant,12} from "@/registry/ui/echarts-tooltip";13import {14 buildChartCss,15 getColorsCount,16 resolveColors,17 withAlpha,18 type ChartConfig,19 type ResolvedColors,20} from "@/registry/ui/echarts-chart";21import {22 Children,23 isValidElement,24 useCallback,25 useEffect,26 useId,27 useMemo,28 useRef,29 useState,30 type FC,31 type ReactNode,32} from "react";33import { TooltipComponent, type TooltipComponentOption } from "echarts/components";34import { SankeyChart, type SankeySeriesOption } from "echarts/charts";35import { motion, useReducedMotion } from "motion/react";36import { CanvasRenderer } from "echarts/renderers";37import type { ComposeOption } from "echarts/core";38import * as echarts from "echarts/core";3940// Re-export the shared types that were previously declared inline here, so41// existing consumers/examples keep importing them from the chart module.42export type { ChartConfig, TooltipPosition, TooltipRoundness, TooltipVariant };4344// Modular registration keeps the bundle lean — only the pieces this chart needs.45// A sankey draws its own node/link geometry, so there is no grid, axis, or46// dataZoom here; the tooltip is the one extra component. GraphicComponent is47// deliberately NOT registered — this chart adds no raw graphic overlays.48echarts.use([SankeyChart, TooltipComponent, CanvasRenderer]);4950type EChartsInstance = ReturnType<typeof echarts.init>;5152// The exact option surface this chart uses — a sankey series plus the tooltip.53// Narrower than echarts' full EChartsOption, so a misspelled key fails the54// compile instead of silently reaching setOption.55type EChartsOption = ComposeOption<SankeySeriesOption | TooltipComponentOption>;5657// Single-item views of the composed series' node/link arrays — the modular entry58// points don't export the sankey node/edge item option types directly, so derive59// them from the composed series to keep the builders fully type-checked.60type SankeyNodeItem = NonNullable<SankeySeriesOption["data"]>[number];61type SankeyEdgeItem = NonNullable<SankeySeriesOption["links"]>[number];6263// ─────────────────────────────────────────────────────────────────────────────64// Constants65// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from EvilCharts
All 271 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| echarts-area-chartecharts-area-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-bar-chartecharts-bar-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-brushecharts-brush | EvilCharts | Components | Free | 1 dep | |
| echarts-chartecharts-chart | EvilCharts | Components | Free | 1 dep | |
| echarts-composed-chartecharts-composed-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-dotecharts-dot | EvilCharts | Components | Free | 1 dep | |
| echarts-legendecharts-legend | EvilCharts | Components | Free | no deps | |
| echarts-line-chartecharts-line-chart | EvilCharts | Components | Free | 2 deps |
