echarts-chart
evilcharts/echarts-chartFreeComponent
EvilCharts publishes no description for this item.
Install it
npx shadcn@latest add https://evilcharts.com/r/echarts-chart.jsonSource
1import type { ComponentType, ReactNode } from "react";2import * as echarts from "echarts/core";34// ─────────────────────────────────────────────────────────────────────────────5// Theme keys + config — replicated from the repo's <ChartStyle> so the ECharts6// charts stay self-contained (no recharts ui imports). Shared by every ECharts7// chart and the tooltip/legend/brush ui modules.8// ─────────────────────────────────────────────────────────────────────────────910// Theme selectors mirror the repo's <ChartStyle>: light is the bare root, dark is `.dark`.11export const THEMES = { light: "", dark: ".dark" } as const;12export type ThemeKey = keyof typeof THEMES;13export const THEME_KEYS = Object.keys(THEMES) as ThemeKey[];1415// Require at least one theme key — identical constraint to the repo's ChartConfig.16export type AtLeastOneThemeColor =17 | { light: string[]; dark?: string[] }18 | { light?: string[]; dark: string[] };1920export type ChartConfig = Record<21 string,22 {23 label?: ReactNode;24 icon?: ComponentType;25 colors?: AtLeastOneThemeColor;26 }27>;2829// ─────────────────────────────────────────────────────────────────────────────30// Color plumbing — replicated from the repo's <ChartStyle> so the charts stay31// self-contained (no @/registry/ui/recharts imports).32// ─────────────────────────────────────────────────────────────────────────────3334// Max slots a key needs = longest color array across themes (min 1). Both themes35// always emit the same number of `--color-{key}-{n}` vars.36export function getColorsCount(item: ChartConfig[string]): number {37 if (!item.colors) return 1;38 const counts = THEME_KEYS.map((theme) => item.colors?.[theme]?.length ?? 0);39 return Math.max(...counts, 1);40}4142// Distribute colors evenly across slots; extra slots go to the LAST color(s).43// … truncated
What it pulls in
npm packages
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-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 | |
| echarts-pie-chartecharts-pie-chart | EvilCharts | Components | Free | 2 deps |
