|
1 | | -# @shadcn/echarts |
| 1 | +# @devstool/shadcn-echarts |
2 | 2 |
|
3 | | -Apache ECharts charts styled to match shadcn/ui's design language with full dark/light mode support and excellent developer experience. |
| 3 | +Apache ECharts components styled to match shadcn/ui design language with automatic light/dark theming, minimal defaults, and tree-shakeable chart exports. |
4 | 4 |
|
5 | | -## 🚧 Work in Progress |
| 5 | +## What you get |
6 | 6 |
|
7 | | -This package is currently under active development. Phase 1 (Core Package Setup) is complete. |
| 7 | +- shadcn-style visual language with CSS variable driven theming |
| 8 | +- Auto dark/light mode sync |
| 9 | +- Defaults-only minimal preset that does not override explicit styling |
| 10 | +- Tree-shakeable per-chart imports |
| 11 | +- npm package + shadcn registry distribution |
8 | 12 |
|
9 | | -## Features |
| 13 | +## Installation methods |
10 | 14 |
|
11 | | -- 🎨 **shadcn/ui Design Language**: Charts automatically match your shadcn/ui theme |
12 | | -- 🌓 **Dark/Light Mode**: Seamless theme switching with automatic detection |
13 | | -- 📦 **Tree-shakeable**: Import only what you need for optimal bundle size |
14 | | -- 🔒 **Type-safe**: Full TypeScript support with ECharts' ComposeOption pattern |
15 | | -- ⚡ **SSR Support**: Server-side rendering utilities included |
16 | | -- 🎯 **Developer Experience**: Clean API with React hooks and utilities |
| 15 | +### 1) npm package |
17 | 16 |
|
18 | | -## Installation |
| 17 | +```bash |
| 18 | +pnpm add @devstool/shadcn-echarts echarts react |
| 19 | +``` |
| 20 | + |
| 21 | +### 2) shadcn direct URL install |
19 | 22 |
|
20 | 23 | ```bash |
21 | | -pnpm add @shadcn/echarts echarts react |
| 24 | +npx shadcn@latest add https://shadcn-echarts.vercel.app/r/bar-chart.json |
22 | 25 | ``` |
23 | 26 |
|
24 | | -## Usage |
| 27 | +### 3) shadcn namespace install |
| 28 | + |
| 29 | +Add a registry namespace in your `components.json`: |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "registries": { |
| 34 | + "@devstool": "https://shadcn-echarts.vercel.app/r/{name}.json" |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +Then install by namespace: |
| 40 | + |
| 41 | +```bash |
| 42 | +npx shadcn@latest add @devstool/bar-chart |
| 43 | +``` |
25 | 44 |
|
26 | | -### Basic Example |
| 45 | +### 4) Manual source ownership |
| 46 | + |
| 47 | +Copy files from `registry/default/*` into your project and customize freely. |
| 48 | + |
| 49 | +## Usage |
27 | 50 |
|
28 | 51 | ```tsx |
29 | | -import { BarChart } from '@shadcn/echarts' |
30 | | -import { useEChartsTheme } from '@shadcn/echarts/hooks' |
| 52 | +import { BarChart } from "@devstool/shadcn-echarts"; |
31 | 53 |
|
32 | | -function MyChart() { |
33 | | - const { theme } = useEChartsTheme() |
34 | | - |
| 54 | +export function MyChart() { |
35 | 55 | return ( |
36 | 56 | <BarChart |
37 | | - data={[5, 20, 36, 10, 10, 20]} |
38 | | - categories={['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']} |
39 | | - theme={theme} |
| 57 | + option={{ |
| 58 | + xAxis: { type: "category", data: ["Mon", "Tue", "Wed"] }, |
| 59 | + yAxis: { type: "value" }, |
| 60 | + series: [{ type: "bar", data: [150, 230, 224] }], |
| 61 | + }} |
| 62 | + height={320} |
40 | 63 | /> |
41 | | - ) |
| 64 | + ); |
42 | 65 | } |
43 | 66 | ``` |
44 | 67 |
|
45 | | -### Theme Setup |
| 68 | +## Local development |
46 | 69 |
|
47 | | -```tsx |
48 | | -import { registerShadcnThemes } from '@shadcn/echarts/themes' |
| 70 | +```bash |
| 71 | +# library build/watch |
| 72 | +pnpm build |
| 73 | +pnpm dev |
| 74 | + |
| 75 | +# registry assets for docs site |
| 76 | +pnpm registry:build |
| 77 | +pnpm registry:verify |
49 | 78 |
|
50 | | -// Register themes on app initialization |
51 | | -registerShadcnThemes() |
| 79 | +# public docs website |
| 80 | +pnpm www:dev |
| 81 | +pnpm www:build |
| 82 | + |
| 83 | +# interactive demo workspace |
| 84 | +pnpm -C demo dev |
52 | 85 | ``` |
53 | 86 |
|
54 | | -## Documentation |
| 87 | +## Registry endpoints |
| 88 | + |
| 89 | +- Registry index: `/registry.json` |
| 90 | +- Registry items: `/r/<component>.json` |
| 91 | + |
| 92 | +On Vercel this resolves to: |
| 93 | + |
| 94 | +- `https://shadcn-echarts.vercel.app/registry.json` |
| 95 | +- `https://shadcn-echarts.vercel.app/r/bar-chart.json` |
| 96 | + |
| 97 | +## Project docs |
55 | 98 |
|
56 | | -Full documentation coming soon. See the [implementation plan](.cursor/plans/shadcn-echarts_implementation_plan_44021a4f.plan.md) for current progress. |
| 99 | +- `docs/polish/style-spec.md` |
| 100 | +- `docs/polish/presets.md` |
| 101 | +- `docs/polish/theming.md` |
| 102 | +- `docs/release/vercel-github-checklist.md` |
57 | 103 |
|
58 | 104 | ## License |
59 | 105 |
|
|
0 commit comments