@particle-academy/fancy-echarts 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/docs/EChart.md +207 -207
- package/docs/EChart3D.md +178 -178
- package/docs/EChartGraphic.md +149 -149
- package/docs/registration.md +152 -152
- package/docs/themes.md +152 -152
- package/docs/useECharts.md +129 -129
- package/package.json +71 -66
package/docs/EChart.md
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
# EChart
|
|
2
|
-
|
|
3
|
-
Base chart component and compound series sub-components for rendering any ECharts chart type in React.
|
|
4
|
-
|
|
5
|
-
## Import
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
import { EChart } from "@particle-academy/fancy-echarts";
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Base Component
|
|
12
|
-
|
|
13
|
-
`EChart` accepts a raw ECharts option object for full control.
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
<EChart
|
|
17
|
-
option={{
|
|
18
|
-
xAxis: { type: "category", data: ["Mon", "Tue", "Wed"] },
|
|
19
|
-
yAxis: { type: "value" },
|
|
20
|
-
series: [{ type: "line", data: [150, 230, 224] }],
|
|
21
|
-
}}
|
|
22
|
-
style={{ height: 400 }}
|
|
23
|
-
/>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Base Props
|
|
27
|
-
|
|
28
|
-
| Prop | Type | Default | Description |
|
|
29
|
-
|------|------|---------|-------------|
|
|
30
|
-
| `option` | `EChartsOption` | **required** | Full ECharts option object |
|
|
31
|
-
| `theme` | `string \| object` | `undefined` | Theme name or object. Auto-detects dark mode when omitted |
|
|
32
|
-
| `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
|
|
33
|
-
| `notMerge` | `boolean` | `false` | Replace option instead of merging |
|
|
34
|
-
| `lazyUpdate` | `boolean` | `false` | Delay chart update |
|
|
35
|
-
| `showLoading` | `boolean` | `false` | Show loading animation |
|
|
36
|
-
| `loadingOption` | `object` | `undefined` | Customize loading spinner |
|
|
37
|
-
| `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers keyed by event name |
|
|
38
|
-
| `autoResize` | `boolean` | `true` | Auto-resize on container size change |
|
|
39
|
-
| `style` | `CSSProperties` | `{ width: "100%", height: 400 }` | Container styles |
|
|
40
|
-
| `className` | `string` | `undefined` | CSS class name |
|
|
41
|
-
|
|
42
|
-
Also accepts any `HTMLDivElement` attribute.
|
|
43
|
-
|
|
44
|
-
## Series Sub-Components
|
|
45
|
-
|
|
46
|
-
All sub-components share a simplified props API. They build the ECharts option internally.
|
|
47
|
-
|
|
48
|
-
### Shared Series Props
|
|
49
|
-
|
|
50
|
-
| Prop | Type | Default | Description |
|
|
51
|
-
|------|------|---------|-------------|
|
|
52
|
-
| `data` | `any[] \| { categories?, series[] }` | **required** | Chart data (see formats below) |
|
|
53
|
-
| `title` | `string` | `undefined` | Chart title text |
|
|
54
|
-
| `xAxis` | `EChartsOption["xAxis"]` | `{ type: "category" }` | X-axis config (axis charts only) |
|
|
55
|
-
| `yAxis` | `EChartsOption["yAxis"]` | `{ type: "value" }` | Y-axis config (axis charts only) |
|
|
56
|
-
| `tooltip` | `boolean \| object` | `true` | Tooltip config. `true` = `{ trigger: "axis" }` |
|
|
57
|
-
| `legend` | `boolean \| object` | `false` | Legend config. `true` = default legend |
|
|
58
|
-
| `grid` | `EChartsOption["grid"]` | `undefined` | Grid layout config |
|
|
59
|
-
| `seriesOptions` | `Record<string, any>` | `{}` | Extra options merged into each series |
|
|
60
|
-
| `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last (overrides everything) |
|
|
61
|
-
|
|
62
|
-
Plus all base props (`theme`, `renderer`, `autoResize`, etc.) and HTML div attributes.
|
|
63
|
-
|
|
64
|
-
### Data Formats
|
|
65
|
-
|
|
66
|
-
**Single series** -- pass an array directly:
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
<EChart.Line data={[150, 230, 224, 218, 135]} />
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Multi-series** -- pass an object with `categories` and `series`:
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
<EChart.Bar
|
|
76
|
-
data={{
|
|
77
|
-
categories: ["Q1", "Q2", "Q3", "Q4"],
|
|
78
|
-
series: [
|
|
79
|
-
{ name: "2024", data: [120, 200, 150, 80] },
|
|
80
|
-
{ name: "2025", data: [180, 230, 190, 140] },
|
|
81
|
-
],
|
|
82
|
-
}}
|
|
83
|
-
legend
|
|
84
|
-
/>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Available Sub-Components
|
|
88
|
-
|
|
89
|
-
### Axis-based charts
|
|
90
|
-
|
|
91
|
-
These automatically configure `xAxis` / `yAxis`.
|
|
92
|
-
|
|
93
|
-
| Component | Series Type | Typical Data |
|
|
94
|
-
|-----------|-------------|-------------|
|
|
95
|
-
| `EChart.Line` | `line` | `number[]` or `[x, y][]` |
|
|
96
|
-
| `EChart.Bar` | `bar` | `number[]` or `[x, y][]` |
|
|
97
|
-
| `EChart.Scatter` | `scatter` | `[x, y][]` |
|
|
98
|
-
| `EChart.Candlestick` | `candlestick` | `[open, close, low, high][]` |
|
|
99
|
-
| `EChart.Boxplot` | `boxplot` | `[min, Q1, median, Q3, max][]` |
|
|
100
|
-
| `EChart.Heatmap` | `heatmap` | `[x, y, value][]` |
|
|
101
|
-
| `EChart.EffectScatter` | `effectScatter` | `[x, y][]` |
|
|
102
|
-
| `EChart.PictorialBar` | `pictorialBar` | `number[]` |
|
|
103
|
-
|
|
104
|
-
### Non-axis charts
|
|
105
|
-
|
|
106
|
-
These do NOT auto-configure axes.
|
|
107
|
-
|
|
108
|
-
| Component | Series Type | Typical Data |
|
|
109
|
-
|-----------|-------------|-------------|
|
|
110
|
-
| `EChart.Pie` | `pie` | `{ name, value }[]` |
|
|
111
|
-
| `EChart.Radar` | `radar` | `{ name, value[] }[]` (requires `radar` in `option`) |
|
|
112
|
-
| `EChart.Gauge` | `gauge` | `{ value, name? }[]` |
|
|
113
|
-
| `EChart.Funnel` | `funnel` | `{ name, value }[]` |
|
|
114
|
-
| `EChart.Treemap` | `treemap` | `{ name, value, children? }[]` |
|
|
115
|
-
| `EChart.Sunburst` | `sunburst` | `{ name, value?, children? }[]` |
|
|
116
|
-
| `EChart.Sankey` | `sankey` | Requires `nodes` and `links` via `seriesOptions` |
|
|
117
|
-
| `EChart.Graph` | `graph` | Requires `nodes` and `links` via `seriesOptions` |
|
|
118
|
-
| `EChart.Parallel` | `parallel` | `number[][]` (requires `parallelAxis` in `option`) |
|
|
119
|
-
| `EChart.ThemeRiver` | `themeRiver` | `[date, value, name][]` |
|
|
120
|
-
| `EChart.Map` | `map` | `{ name, value }[]` (requires map registration + `seriesOptions.map`) |
|
|
121
|
-
| `EChart.Custom` | `custom` | Any (requires `seriesOptions.renderItem`) |
|
|
122
|
-
|
|
123
|
-
## Examples
|
|
124
|
-
|
|
125
|
-
### Line Chart
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
<EChart.Line
|
|
129
|
-
title="Monthly Sales"
|
|
130
|
-
data={[820, 932, 901, 934, 1290, 1330, 1320]}
|
|
131
|
-
seriesOptions={{ smooth: true, areaStyle: {} }}
|
|
132
|
-
/>
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Pie Chart
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
<EChart.Pie
|
|
139
|
-
title="Browser Share"
|
|
140
|
-
data={[
|
|
141
|
-
{ name: "Chrome", value: 65 },
|
|
142
|
-
{ name: "Firefox", value: 15 },
|
|
143
|
-
{ name: "Safari", value: 12 },
|
|
144
|
-
{ name: "Edge", value: 8 },
|
|
145
|
-
]}
|
|
146
|
-
seriesOptions={{ radius: ["40%", "70%"] }}
|
|
147
|
-
legend
|
|
148
|
-
/>
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Multi-Series Bar
|
|
152
|
-
|
|
153
|
-
```tsx
|
|
154
|
-
<EChart.Bar
|
|
155
|
-
title="Revenue by Quarter"
|
|
156
|
-
data={{
|
|
157
|
-
categories: ["Q1", "Q2", "Q3", "Q4"],
|
|
158
|
-
series: [
|
|
159
|
-
{ name: "Product A", data: [120, 200, 150, 80] },
|
|
160
|
-
{ name: "Product B", data: [60, 140, 190, 220] },
|
|
161
|
-
],
|
|
162
|
-
}}
|
|
163
|
-
legend
|
|
164
|
-
/>
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Scatter with Event Handling
|
|
168
|
-
|
|
169
|
-
```tsx
|
|
170
|
-
<EChart.Scatter
|
|
171
|
-
data={[[10, 20], [30, 40], [50, 60], [70, 80]]}
|
|
172
|
-
seriesOptions={{ symbolSize: 12 }}
|
|
173
|
-
onEvents={{
|
|
174
|
-
click: (params) => console.log("Clicked:", params.data),
|
|
175
|
-
}}
|
|
176
|
-
/>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Gauge
|
|
180
|
-
|
|
181
|
-
```tsx
|
|
182
|
-
<EChart.Gauge
|
|
183
|
-
data={[{ value: 72, name: "Completion" }]}
|
|
184
|
-
seriesOptions={{ detail: { formatter: "{value}%" } }}
|
|
185
|
-
/>
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Full Control via Base Component
|
|
189
|
-
|
|
190
|
-
```tsx
|
|
191
|
-
<EChart
|
|
192
|
-
option={{
|
|
193
|
-
radar: {
|
|
194
|
-
indicator: [
|
|
195
|
-
{ name: "Sales", max: 100 },
|
|
196
|
-
{ name: "Admin", max: 100 },
|
|
197
|
-
{ name: "Tech", max: 100 },
|
|
198
|
-
],
|
|
199
|
-
},
|
|
200
|
-
series: [{
|
|
201
|
-
type: "radar",
|
|
202
|
-
data: [{ value: [80, 60, 90], name: "Team A" }],
|
|
203
|
-
}],
|
|
204
|
-
}}
|
|
205
|
-
theme="dark-preset"
|
|
206
|
-
/>
|
|
207
|
-
```
|
|
1
|
+
# EChart
|
|
2
|
+
|
|
3
|
+
Base chart component and compound series sub-components for rendering any ECharts chart type in React.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { EChart } from "@particle-academy/fancy-echarts";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Base Component
|
|
12
|
+
|
|
13
|
+
`EChart` accepts a raw ECharts option object for full control.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<EChart
|
|
17
|
+
option={{
|
|
18
|
+
xAxis: { type: "category", data: ["Mon", "Tue", "Wed"] },
|
|
19
|
+
yAxis: { type: "value" },
|
|
20
|
+
series: [{ type: "line", data: [150, 230, 224] }],
|
|
21
|
+
}}
|
|
22
|
+
style={{ height: 400 }}
|
|
23
|
+
/>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Base Props
|
|
27
|
+
|
|
28
|
+
| Prop | Type | Default | Description |
|
|
29
|
+
|------|------|---------|-------------|
|
|
30
|
+
| `option` | `EChartsOption` | **required** | Full ECharts option object |
|
|
31
|
+
| `theme` | `string \| object` | `undefined` | Theme name or object. Auto-detects dark mode when omitted |
|
|
32
|
+
| `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
|
|
33
|
+
| `notMerge` | `boolean` | `false` | Replace option instead of merging |
|
|
34
|
+
| `lazyUpdate` | `boolean` | `false` | Delay chart update |
|
|
35
|
+
| `showLoading` | `boolean` | `false` | Show loading animation |
|
|
36
|
+
| `loadingOption` | `object` | `undefined` | Customize loading spinner |
|
|
37
|
+
| `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers keyed by event name |
|
|
38
|
+
| `autoResize` | `boolean` | `true` | Auto-resize on container size change |
|
|
39
|
+
| `style` | `CSSProperties` | `{ width: "100%", height: 400 }` | Container styles |
|
|
40
|
+
| `className` | `string` | `undefined` | CSS class name |
|
|
41
|
+
|
|
42
|
+
Also accepts any `HTMLDivElement` attribute.
|
|
43
|
+
|
|
44
|
+
## Series Sub-Components
|
|
45
|
+
|
|
46
|
+
All sub-components share a simplified props API. They build the ECharts option internally.
|
|
47
|
+
|
|
48
|
+
### Shared Series Props
|
|
49
|
+
|
|
50
|
+
| Prop | Type | Default | Description |
|
|
51
|
+
|------|------|---------|-------------|
|
|
52
|
+
| `data` | `any[] \| { categories?, series[] }` | **required** | Chart data (see formats below) |
|
|
53
|
+
| `title` | `string` | `undefined` | Chart title text |
|
|
54
|
+
| `xAxis` | `EChartsOption["xAxis"]` | `{ type: "category" }` | X-axis config (axis charts only) |
|
|
55
|
+
| `yAxis` | `EChartsOption["yAxis"]` | `{ type: "value" }` | Y-axis config (axis charts only) |
|
|
56
|
+
| `tooltip` | `boolean \| object` | `true` | Tooltip config. `true` = `{ trigger: "axis" }` |
|
|
57
|
+
| `legend` | `boolean \| object` | `false` | Legend config. `true` = default legend |
|
|
58
|
+
| `grid` | `EChartsOption["grid"]` | `undefined` | Grid layout config |
|
|
59
|
+
| `seriesOptions` | `Record<string, any>` | `{}` | Extra options merged into each series |
|
|
60
|
+
| `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last (overrides everything) |
|
|
61
|
+
|
|
62
|
+
Plus all base props (`theme`, `renderer`, `autoResize`, etc.) and HTML div attributes.
|
|
63
|
+
|
|
64
|
+
### Data Formats
|
|
65
|
+
|
|
66
|
+
**Single series** -- pass an array directly:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<EChart.Line data={[150, 230, 224, 218, 135]} />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Multi-series** -- pass an object with `categories` and `series`:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<EChart.Bar
|
|
76
|
+
data={{
|
|
77
|
+
categories: ["Q1", "Q2", "Q3", "Q4"],
|
|
78
|
+
series: [
|
|
79
|
+
{ name: "2024", data: [120, 200, 150, 80] },
|
|
80
|
+
{ name: "2025", data: [180, 230, 190, 140] },
|
|
81
|
+
],
|
|
82
|
+
}}
|
|
83
|
+
legend
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Available Sub-Components
|
|
88
|
+
|
|
89
|
+
### Axis-based charts
|
|
90
|
+
|
|
91
|
+
These automatically configure `xAxis` / `yAxis`.
|
|
92
|
+
|
|
93
|
+
| Component | Series Type | Typical Data |
|
|
94
|
+
|-----------|-------------|-------------|
|
|
95
|
+
| `EChart.Line` | `line` | `number[]` or `[x, y][]` |
|
|
96
|
+
| `EChart.Bar` | `bar` | `number[]` or `[x, y][]` |
|
|
97
|
+
| `EChart.Scatter` | `scatter` | `[x, y][]` |
|
|
98
|
+
| `EChart.Candlestick` | `candlestick` | `[open, close, low, high][]` |
|
|
99
|
+
| `EChart.Boxplot` | `boxplot` | `[min, Q1, median, Q3, max][]` |
|
|
100
|
+
| `EChart.Heatmap` | `heatmap` | `[x, y, value][]` |
|
|
101
|
+
| `EChart.EffectScatter` | `effectScatter` | `[x, y][]` |
|
|
102
|
+
| `EChart.PictorialBar` | `pictorialBar` | `number[]` |
|
|
103
|
+
|
|
104
|
+
### Non-axis charts
|
|
105
|
+
|
|
106
|
+
These do NOT auto-configure axes.
|
|
107
|
+
|
|
108
|
+
| Component | Series Type | Typical Data |
|
|
109
|
+
|-----------|-------------|-------------|
|
|
110
|
+
| `EChart.Pie` | `pie` | `{ name, value }[]` |
|
|
111
|
+
| `EChart.Radar` | `radar` | `{ name, value[] }[]` (requires `radar` in `option`) |
|
|
112
|
+
| `EChart.Gauge` | `gauge` | `{ value, name? }[]` |
|
|
113
|
+
| `EChart.Funnel` | `funnel` | `{ name, value }[]` |
|
|
114
|
+
| `EChart.Treemap` | `treemap` | `{ name, value, children? }[]` |
|
|
115
|
+
| `EChart.Sunburst` | `sunburst` | `{ name, value?, children? }[]` |
|
|
116
|
+
| `EChart.Sankey` | `sankey` | Requires `nodes` and `links` via `seriesOptions` |
|
|
117
|
+
| `EChart.Graph` | `graph` | Requires `nodes` and `links` via `seriesOptions` |
|
|
118
|
+
| `EChart.Parallel` | `parallel` | `number[][]` (requires `parallelAxis` in `option`) |
|
|
119
|
+
| `EChart.ThemeRiver` | `themeRiver` | `[date, value, name][]` |
|
|
120
|
+
| `EChart.Map` | `map` | `{ name, value }[]` (requires map registration + `seriesOptions.map`) |
|
|
121
|
+
| `EChart.Custom` | `custom` | Any (requires `seriesOptions.renderItem`) |
|
|
122
|
+
|
|
123
|
+
## Examples
|
|
124
|
+
|
|
125
|
+
### Line Chart
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<EChart.Line
|
|
129
|
+
title="Monthly Sales"
|
|
130
|
+
data={[820, 932, 901, 934, 1290, 1330, 1320]}
|
|
131
|
+
seriesOptions={{ smooth: true, areaStyle: {} }}
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Pie Chart
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
<EChart.Pie
|
|
139
|
+
title="Browser Share"
|
|
140
|
+
data={[
|
|
141
|
+
{ name: "Chrome", value: 65 },
|
|
142
|
+
{ name: "Firefox", value: 15 },
|
|
143
|
+
{ name: "Safari", value: 12 },
|
|
144
|
+
{ name: "Edge", value: 8 },
|
|
145
|
+
]}
|
|
146
|
+
seriesOptions={{ radius: ["40%", "70%"] }}
|
|
147
|
+
legend
|
|
148
|
+
/>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Multi-Series Bar
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
<EChart.Bar
|
|
155
|
+
title="Revenue by Quarter"
|
|
156
|
+
data={{
|
|
157
|
+
categories: ["Q1", "Q2", "Q3", "Q4"],
|
|
158
|
+
series: [
|
|
159
|
+
{ name: "Product A", data: [120, 200, 150, 80] },
|
|
160
|
+
{ name: "Product B", data: [60, 140, 190, 220] },
|
|
161
|
+
],
|
|
162
|
+
}}
|
|
163
|
+
legend
|
|
164
|
+
/>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Scatter with Event Handling
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
<EChart.Scatter
|
|
171
|
+
data={[[10, 20], [30, 40], [50, 60], [70, 80]]}
|
|
172
|
+
seriesOptions={{ symbolSize: 12 }}
|
|
173
|
+
onEvents={{
|
|
174
|
+
click: (params) => console.log("Clicked:", params.data),
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Gauge
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
<EChart.Gauge
|
|
183
|
+
data={[{ value: 72, name: "Completion" }]}
|
|
184
|
+
seriesOptions={{ detail: { formatter: "{value}%" } }}
|
|
185
|
+
/>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Full Control via Base Component
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<EChart
|
|
192
|
+
option={{
|
|
193
|
+
radar: {
|
|
194
|
+
indicator: [
|
|
195
|
+
{ name: "Sales", max: 100 },
|
|
196
|
+
{ name: "Admin", max: 100 },
|
|
197
|
+
{ name: "Tech", max: 100 },
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
series: [{
|
|
201
|
+
type: "radar",
|
|
202
|
+
data: [{ value: [80, 60, 90], name: "Team A" }],
|
|
203
|
+
}],
|
|
204
|
+
}}
|
|
205
|
+
theme="dark-preset"
|
|
206
|
+
/>
|
|
207
|
+
```
|