@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/docs/EChart3D.md CHANGED
@@ -1,178 +1,178 @@
1
- # EChart3D
2
-
3
- 3D chart component that lazy-loads `echarts-gl` and provides sub-components for common 3D chart types.
4
-
5
- ## Import
6
-
7
- ```tsx
8
- import { EChart3D } from "@particle-academy/fancy-echarts";
9
- ```
10
-
11
- `echarts-gl` is bundled — no extra peer dependency install is required. The GL engine is dynamically loaded on first render of an `EChart3D`.
12
-
13
- ## Base Component
14
-
15
- `EChart3D` accepts a raw ECharts option (including 3D-specific options like `grid3D`, `xAxis3D`, etc.). It automatically lazy-loads `echarts-gl` and shows a "Loading 3D engine..." placeholder until ready.
16
-
17
- ```tsx
18
- <EChart3D
19
- option={{
20
- grid3D: {},
21
- xAxis3D: { type: "value" },
22
- yAxis3D: { type: "value" },
23
- zAxis3D: { type: "value" },
24
- series: [{
25
- type: "scatter3D",
26
- data: [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
27
- }],
28
- }}
29
- />
30
- ```
31
-
32
- ### Base Props
33
-
34
- | Prop | Type | Default | Description |
35
- |------|------|---------|-------------|
36
- | `option` | `EChartsOption` | **required** | Full ECharts option including 3D config |
37
- | `theme` | `string \| object` | `undefined` | Theme name or object |
38
- | `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
39
- | `notMerge` | `boolean` | `false` | Replace option instead of merging |
40
- | `lazyUpdate` | `boolean` | `false` | Delay chart update |
41
- | `showLoading` | `boolean` | `false` | Show loading animation |
42
- | `loadingOption` | `object` | `undefined` | Customize loading spinner |
43
- | `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers |
44
- | `autoResize` | `boolean` | `true` | Auto-resize on container change |
45
- | `style` | `CSSProperties` | `{ width: "100%", height: 500 }` | Container styles |
46
- | `className` | `string` | `undefined` | CSS class name |
47
-
48
- ## Sub-Components
49
-
50
- ### Shared Series Props
51
-
52
- | Prop | Type | Default | Description |
53
- |------|------|---------|-------------|
54
- | `data` | `any` | **required** | Chart data (typically `[x, y, z][]`) |
55
- | `title` | `string` | `undefined` | Chart title |
56
- | `tooltip` | `boolean \| object` | `true` | Tooltip config |
57
- | `seriesOptions` | `Record<string, any>` | `{}` | Extra options merged into the series |
58
- | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last |
59
- | `style` | `CSSProperties` | `undefined` | Container styles |
60
- | `className` | `string` | `undefined` | CSS class name |
61
-
62
- ### EChart3D.Bar
63
-
64
- 3D bar chart. Auto-configures `xAxis3D`, `yAxis3D`, `zAxis3D`, and `grid3D`.
65
-
66
- ```tsx
67
- <EChart3D.Bar
68
- title="3D Bars"
69
- data={[[0, 0, 5], [0, 1, 3], [1, 0, 8], [1, 1, 2]]}
70
- />
71
- ```
72
-
73
- **Data format:** `[x, y, z][]`
74
-
75
- ### EChart3D.Scatter
76
-
77
- 3D scatter plot. Auto-configures 3D axes and grid.
78
-
79
- ```tsx
80
- <EChart3D.Scatter
81
- data={[[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 4, 6]]}
82
- seriesOptions={{ symbolSize: 8 }}
83
- />
84
- ```
85
-
86
- **Data format:** `[x, y, z][]`
87
-
88
- ### EChart3D.Line
89
-
90
- 3D line chart. Auto-configures 3D axes and grid.
91
-
92
- ```tsx
93
- <EChart3D.Line
94
- data={[[0, 0, 0], [1, 1, 1], [2, 4, 8], [3, 9, 27]]}
95
- />
96
- ```
97
-
98
- **Data format:** `[x, y, z][]`
99
-
100
- ### EChart3D.Surface
101
-
102
- 3D surface chart. Auto-configures 3D axes and grid.
103
-
104
- ```tsx
105
- <EChart3D.Surface
106
- title="Surface"
107
- seriesOptions={{
108
- wireframe: { show: true },
109
- equation: {
110
- x: { min: -3, max: 3, step: 0.1 },
111
- y: { min: -3, max: 3, step: 0.1 },
112
- z: (x, y) => Math.sin(x * x + y * y) * x / Math.PI,
113
- },
114
- }}
115
- />
116
- ```
117
-
118
- **Data format:** `[x, y, z][]` or use `seriesOptions.equation` for parametric surfaces.
119
-
120
- ### EChart3D.Globe
121
-
122
- Globe visualization. Uses a different prop interface -- no `data` prop. Configure via `globe` and `series`.
123
-
124
- ```tsx
125
- <EChart3D.Globe
126
- title="Earth"
127
- globe={{
128
- baseTexture: "/earth-texture.jpg",
129
- heightTexture: "/earth-height.jpg",
130
- shading: "lambert",
131
- atmosphere: { show: true },
132
- }}
133
- series={[{
134
- type: "scatter3D",
135
- coordinateSystem: "globe",
136
- data: [[-74, 40.7, 1000], [2.35, 48.86, 800]],
137
- }]}
138
- />
139
- ```
140
-
141
- #### Globe Props
142
-
143
- | Prop | Type | Default | Description |
144
- |------|------|---------|-------------|
145
- | `title` | `string` | `undefined` | Chart title |
146
- | `globe` | `object` | `{ baseTexture: "", shading: "lambert", atmosphere: { show: true } }` | Globe configuration |
147
- | `series` | `any[]` | `[]` | Additional series to overlay on the globe |
148
- | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last |
149
-
150
- ## Examples
151
-
152
- ### Scatter with Custom Grid
153
-
154
- ```tsx
155
- <EChart3D.Scatter
156
- title="3D Distribution"
157
- data={points}
158
- seriesOptions={{ symbolSize: 5, itemStyle: { opacity: 0.8 } }}
159
- option={{
160
- grid3D: { viewControl: { autoRotate: true } },
161
- }}
162
- />
163
- ```
164
-
165
- ### Full Control via Base
166
-
167
- ```tsx
168
- <EChart3D
169
- option={{
170
- visualMap: { max: 100, inRange: { color: ["#50a3ba", "#eac736", "#d94e5d"] } },
171
- grid3D: { viewControl: { projection: "orthographic" } },
172
- xAxis3D: {},
173
- yAxis3D: {},
174
- zAxis3D: {},
175
- series: [{ type: "bar3D", data: myData, shading: "lambert" }],
176
- }}
177
- />
178
- ```
1
+ # EChart3D
2
+
3
+ 3D chart component that lazy-loads `echarts-gl` and provides sub-components for common 3D chart types.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { EChart3D } from "@particle-academy/fancy-echarts";
9
+ ```
10
+
11
+ `echarts-gl` is bundled — no extra peer dependency install is required. The GL engine is dynamically loaded on first render of an `EChart3D`.
12
+
13
+ ## Base Component
14
+
15
+ `EChart3D` accepts a raw ECharts option (including 3D-specific options like `grid3D`, `xAxis3D`, etc.). It automatically lazy-loads `echarts-gl` and shows a "Loading 3D engine..." placeholder until ready.
16
+
17
+ ```tsx
18
+ <EChart3D
19
+ option={{
20
+ grid3D: {},
21
+ xAxis3D: { type: "value" },
22
+ yAxis3D: { type: "value" },
23
+ zAxis3D: { type: "value" },
24
+ series: [{
25
+ type: "scatter3D",
26
+ data: [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
27
+ }],
28
+ }}
29
+ />
30
+ ```
31
+
32
+ ### Base Props
33
+
34
+ | Prop | Type | Default | Description |
35
+ |------|------|---------|-------------|
36
+ | `option` | `EChartsOption` | **required** | Full ECharts option including 3D config |
37
+ | `theme` | `string \| object` | `undefined` | Theme name or object |
38
+ | `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
39
+ | `notMerge` | `boolean` | `false` | Replace option instead of merging |
40
+ | `lazyUpdate` | `boolean` | `false` | Delay chart update |
41
+ | `showLoading` | `boolean` | `false` | Show loading animation |
42
+ | `loadingOption` | `object` | `undefined` | Customize loading spinner |
43
+ | `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers |
44
+ | `autoResize` | `boolean` | `true` | Auto-resize on container change |
45
+ | `style` | `CSSProperties` | `{ width: "100%", height: 500 }` | Container styles |
46
+ | `className` | `string` | `undefined` | CSS class name |
47
+
48
+ ## Sub-Components
49
+
50
+ ### Shared Series Props
51
+
52
+ | Prop | Type | Default | Description |
53
+ |------|------|---------|-------------|
54
+ | `data` | `any` | **required** | Chart data (typically `[x, y, z][]`) |
55
+ | `title` | `string` | `undefined` | Chart title |
56
+ | `tooltip` | `boolean \| object` | `true` | Tooltip config |
57
+ | `seriesOptions` | `Record<string, any>` | `{}` | Extra options merged into the series |
58
+ | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last |
59
+ | `style` | `CSSProperties` | `undefined` | Container styles |
60
+ | `className` | `string` | `undefined` | CSS class name |
61
+
62
+ ### EChart3D.Bar
63
+
64
+ 3D bar chart. Auto-configures `xAxis3D`, `yAxis3D`, `zAxis3D`, and `grid3D`.
65
+
66
+ ```tsx
67
+ <EChart3D.Bar
68
+ title="3D Bars"
69
+ data={[[0, 0, 5], [0, 1, 3], [1, 0, 8], [1, 1, 2]]}
70
+ />
71
+ ```
72
+
73
+ **Data format:** `[x, y, z][]`
74
+
75
+ ### EChart3D.Scatter
76
+
77
+ 3D scatter plot. Auto-configures 3D axes and grid.
78
+
79
+ ```tsx
80
+ <EChart3D.Scatter
81
+ data={[[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 4, 6]]}
82
+ seriesOptions={{ symbolSize: 8 }}
83
+ />
84
+ ```
85
+
86
+ **Data format:** `[x, y, z][]`
87
+
88
+ ### EChart3D.Line
89
+
90
+ 3D line chart. Auto-configures 3D axes and grid.
91
+
92
+ ```tsx
93
+ <EChart3D.Line
94
+ data={[[0, 0, 0], [1, 1, 1], [2, 4, 8], [3, 9, 27]]}
95
+ />
96
+ ```
97
+
98
+ **Data format:** `[x, y, z][]`
99
+
100
+ ### EChart3D.Surface
101
+
102
+ 3D surface chart. Auto-configures 3D axes and grid.
103
+
104
+ ```tsx
105
+ <EChart3D.Surface
106
+ title="Surface"
107
+ seriesOptions={{
108
+ wireframe: { show: true },
109
+ equation: {
110
+ x: { min: -3, max: 3, step: 0.1 },
111
+ y: { min: -3, max: 3, step: 0.1 },
112
+ z: (x, y) => Math.sin(x * x + y * y) * x / Math.PI,
113
+ },
114
+ }}
115
+ />
116
+ ```
117
+
118
+ **Data format:** `[x, y, z][]` or use `seriesOptions.equation` for parametric surfaces.
119
+
120
+ ### EChart3D.Globe
121
+
122
+ Globe visualization. Uses a different prop interface -- no `data` prop. Configure via `globe` and `series`.
123
+
124
+ ```tsx
125
+ <EChart3D.Globe
126
+ title="Earth"
127
+ globe={{
128
+ baseTexture: "/earth-texture.jpg",
129
+ heightTexture: "/earth-height.jpg",
130
+ shading: "lambert",
131
+ atmosphere: { show: true },
132
+ }}
133
+ series={[{
134
+ type: "scatter3D",
135
+ coordinateSystem: "globe",
136
+ data: [[-74, 40.7, 1000], [2.35, 48.86, 800]],
137
+ }]}
138
+ />
139
+ ```
140
+
141
+ #### Globe Props
142
+
143
+ | Prop | Type | Default | Description |
144
+ |------|------|---------|-------------|
145
+ | `title` | `string` | `undefined` | Chart title |
146
+ | `globe` | `object` | `{ baseTexture: "", shading: "lambert", atmosphere: { show: true } }` | Globe configuration |
147
+ | `series` | `any[]` | `[]` | Additional series to overlay on the globe |
148
+ | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged last |
149
+
150
+ ## Examples
151
+
152
+ ### Scatter with Custom Grid
153
+
154
+ ```tsx
155
+ <EChart3D.Scatter
156
+ title="3D Distribution"
157
+ data={points}
158
+ seriesOptions={{ symbolSize: 5, itemStyle: { opacity: 0.8 } }}
159
+ option={{
160
+ grid3D: { viewControl: { autoRotate: true } },
161
+ }}
162
+ />
163
+ ```
164
+
165
+ ### Full Control via Base
166
+
167
+ ```tsx
168
+ <EChart3D
169
+ option={{
170
+ visualMap: { max: 100, inRange: { color: ["#50a3ba", "#eac736", "#d94e5d"] } },
171
+ grid3D: { viewControl: { projection: "orthographic" } },
172
+ xAxis3D: {},
173
+ yAxis3D: {},
174
+ zAxis3D: {},
175
+ series: [{ type: "bar3D", data: myData, shading: "lambert" }],
176
+ }}
177
+ />
178
+ ```
@@ -1,149 +1,149 @@
1
- # EChartGraphic
2
-
3
- Component for custom drawing via the ECharts graphic layer. Supports shapes, text, images, and interactive elements.
4
-
5
- ## Import
6
-
7
- ```tsx
8
- import { EChartGraphic } from "@particle-academy/fancy-echarts";
9
- import type { GraphicElement, EChartGraphicProps } from "@particle-academy/fancy-echarts";
10
- ```
11
-
12
- ## Props
13
-
14
- | Prop | Type | Default | Description |
15
- |------|------|---------|-------------|
16
- | `elements` | `GraphicElement[]` | **required** | Array of graphic elements to render |
17
- | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged into the final option |
18
- | `theme` | `string \| object` | `undefined` | Theme name or object |
19
- | `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
20
- | `notMerge` | `boolean` | `false` | Replace option instead of merging |
21
- | `lazyUpdate` | `boolean` | `false` | Delay chart update |
22
- | `showLoading` | `boolean` | `false` | Show loading animation |
23
- | `loadingOption` | `object` | `undefined` | Customize loading spinner |
24
- | `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers |
25
- | `autoResize` | `boolean` | `true` | Auto-resize on container change |
26
- | `style` | `CSSProperties` | `{ width: "100%", height: 400 }` | Container styles |
27
- | `className` | `string` | `undefined` | CSS class name |
28
-
29
- ## GraphicElement
30
-
31
- ```ts
32
- interface GraphicElement {
33
- type: "rect" | "circle" | "ring" | "arc" | "polygon" | "polyline"
34
- | "path" | "image" | "text" | "group";
35
- left?: number | string;
36
- top?: number | string;
37
- right?: number | string;
38
- bottom?: number | string;
39
- shape?: Record<string, any>;
40
- style?: Record<string, any>;
41
- children?: GraphicElement[];
42
- onclick?: (e: any) => void;
43
- onmouseover?: (e: any) => void;
44
- onmouseout?: (e: any) => void;
45
- [key: string]: any; // additional ECharts graphic properties
46
- }
47
- ```
48
-
49
- ## Examples
50
-
51
- ### Basic Shapes
52
-
53
- ```tsx
54
- <EChartGraphic
55
- elements={[
56
- {
57
- type: "rect",
58
- left: 50,
59
- top: 50,
60
- shape: { width: 200, height: 100, r: 8 },
61
- style: { fill: "#5470c6", stroke: "#333", lineWidth: 2 },
62
- },
63
- {
64
- type: "circle",
65
- left: 350,
66
- top: 100,
67
- shape: { r: 50 },
68
- style: { fill: "#91cc75" },
69
- },
70
- {
71
- type: "text",
72
- left: "center",
73
- top: 200,
74
- style: {
75
- text: "Hello ECharts",
76
- fontSize: 24,
77
- fontWeight: "bold",
78
- fill: "#333",
79
- },
80
- },
81
- ]}
82
- />
83
- ```
84
-
85
- ### Interactive Element
86
-
87
- ```tsx
88
- <EChartGraphic
89
- elements={[
90
- {
91
- type: "rect",
92
- left: "center",
93
- top: "middle",
94
- shape: { width: 160, height: 50, r: 10 },
95
- style: { fill: "#5470c6", text: "Click me", fontSize: 16, fill: "#fff" },
96
- onclick: () => alert("Clicked!"),
97
- onmouseover: (e) => { e.target.style.opacity = 0.8; },
98
- onmouseout: (e) => { e.target.style.opacity = 1; },
99
- },
100
- ]}
101
- />
102
- ```
103
-
104
- ### Group with Children
105
-
106
- ```tsx
107
- <EChartGraphic
108
- elements={[
109
- {
110
- type: "group",
111
- left: 100,
112
- top: 100,
113
- children: [
114
- {
115
- type: "rect",
116
- shape: { width: 120, height: 80 },
117
- style: { fill: "#fac858" },
118
- },
119
- {
120
- type: "text",
121
- left: 10,
122
- top: 30,
123
- style: { text: "Grouped", fill: "#333", fontSize: 14 },
124
- },
125
- ],
126
- },
127
- ]}
128
- />
129
- ```
130
-
131
- ### Combined with Chart Option
132
-
133
- ```tsx
134
- <EChartGraphic
135
- elements={[
136
- {
137
- type: "text",
138
- left: "center",
139
- top: 20,
140
- style: { text: "Watermark", fontSize: 48, fill: "rgba(0,0,0,0.05)" },
141
- },
142
- ]}
143
- option={{
144
- xAxis: { type: "category", data: ["A", "B", "C"] },
145
- yAxis: { type: "value" },
146
- series: [{ type: "bar", data: [10, 20, 30] }],
147
- }}
148
- />
149
- ```
1
+ # EChartGraphic
2
+
3
+ Component for custom drawing via the ECharts graphic layer. Supports shapes, text, images, and interactive elements.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { EChartGraphic } from "@particle-academy/fancy-echarts";
9
+ import type { GraphicElement, EChartGraphicProps } from "@particle-academy/fancy-echarts";
10
+ ```
11
+
12
+ ## Props
13
+
14
+ | Prop | Type | Default | Description |
15
+ |------|------|---------|-------------|
16
+ | `elements` | `GraphicElement[]` | **required** | Array of graphic elements to render |
17
+ | `option` | `Partial<EChartsOption>` | `{}` | Extra ECharts options merged into the final option |
18
+ | `theme` | `string \| object` | `undefined` | Theme name or object |
19
+ | `renderer` | `"canvas" \| "svg"` | `"canvas"` | Rendering engine |
20
+ | `notMerge` | `boolean` | `false` | Replace option instead of merging |
21
+ | `lazyUpdate` | `boolean` | `false` | Delay chart update |
22
+ | `showLoading` | `boolean` | `false` | Show loading animation |
23
+ | `loadingOption` | `object` | `undefined` | Customize loading spinner |
24
+ | `onEvents` | `Record<string, (params) => void>` | `undefined` | Event handlers |
25
+ | `autoResize` | `boolean` | `true` | Auto-resize on container change |
26
+ | `style` | `CSSProperties` | `{ width: "100%", height: 400 }` | Container styles |
27
+ | `className` | `string` | `undefined` | CSS class name |
28
+
29
+ ## GraphicElement
30
+
31
+ ```ts
32
+ interface GraphicElement {
33
+ type: "rect" | "circle" | "ring" | "arc" | "polygon" | "polyline"
34
+ | "path" | "image" | "text" | "group";
35
+ left?: number | string;
36
+ top?: number | string;
37
+ right?: number | string;
38
+ bottom?: number | string;
39
+ shape?: Record<string, any>;
40
+ style?: Record<string, any>;
41
+ children?: GraphicElement[];
42
+ onclick?: (e: any) => void;
43
+ onmouseover?: (e: any) => void;
44
+ onmouseout?: (e: any) => void;
45
+ [key: string]: any; // additional ECharts graphic properties
46
+ }
47
+ ```
48
+
49
+ ## Examples
50
+
51
+ ### Basic Shapes
52
+
53
+ ```tsx
54
+ <EChartGraphic
55
+ elements={[
56
+ {
57
+ type: "rect",
58
+ left: 50,
59
+ top: 50,
60
+ shape: { width: 200, height: 100, r: 8 },
61
+ style: { fill: "#5470c6", stroke: "#333", lineWidth: 2 },
62
+ },
63
+ {
64
+ type: "circle",
65
+ left: 350,
66
+ top: 100,
67
+ shape: { r: 50 },
68
+ style: { fill: "#91cc75" },
69
+ },
70
+ {
71
+ type: "text",
72
+ left: "center",
73
+ top: 200,
74
+ style: {
75
+ text: "Hello ECharts",
76
+ fontSize: 24,
77
+ fontWeight: "bold",
78
+ fill: "#333",
79
+ },
80
+ },
81
+ ]}
82
+ />
83
+ ```
84
+
85
+ ### Interactive Element
86
+
87
+ ```tsx
88
+ <EChartGraphic
89
+ elements={[
90
+ {
91
+ type: "rect",
92
+ left: "center",
93
+ top: "middle",
94
+ shape: { width: 160, height: 50, r: 10 },
95
+ style: { fill: "#5470c6", text: "Click me", fontSize: 16, fill: "#fff" },
96
+ onclick: () => alert("Clicked!"),
97
+ onmouseover: (e) => { e.target.style.opacity = 0.8; },
98
+ onmouseout: (e) => { e.target.style.opacity = 1; },
99
+ },
100
+ ]}
101
+ />
102
+ ```
103
+
104
+ ### Group with Children
105
+
106
+ ```tsx
107
+ <EChartGraphic
108
+ elements={[
109
+ {
110
+ type: "group",
111
+ left: 100,
112
+ top: 100,
113
+ children: [
114
+ {
115
+ type: "rect",
116
+ shape: { width: 120, height: 80 },
117
+ style: { fill: "#fac858" },
118
+ },
119
+ {
120
+ type: "text",
121
+ left: 10,
122
+ top: 30,
123
+ style: { text: "Grouped", fill: "#333", fontSize: 14 },
124
+ },
125
+ ],
126
+ },
127
+ ]}
128
+ />
129
+ ```
130
+
131
+ ### Combined with Chart Option
132
+
133
+ ```tsx
134
+ <EChartGraphic
135
+ elements={[
136
+ {
137
+ type: "text",
138
+ left: "center",
139
+ top: 20,
140
+ style: { text: "Watermark", fontSize: 48, fill: "rgba(0,0,0,0.05)" },
141
+ },
142
+ ]}
143
+ option={{
144
+ xAxis: { type: "category", data: ["A", "B", "C"] },
145
+ yAxis: { type: "value" },
146
+ series: [{ type: "bar", data: [10, 20, 30] }],
147
+ }}
148
+ />
149
+ ```