@easy-editor/materials-dashboard-radar-chart 0.0.2 → 0.0.4
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/CHANGELOG.md +14 -0
- package/dist/component.min.js +3 -4
- package/dist/index.min.js +3 -4
- package/dist/meta.min.js +1 -2
- package/easypack.config.ts +10 -0
- package/package.json +4 -8
- package/src/component.tsx +244 -199
- package/src/configure.ts +135 -247
- package/src/index.tsx +7 -7
- package/src/meta.ts +23 -23
- package/src/snippets.ts +86 -57
- package/tsconfig.json +20 -9
- package/.vite/plugins/vite-plugin-external-deps.ts +0 -224
- package/.vite/plugins/vite-plugin-material-dev.ts +0 -218
- package/dist/component.esm.js +0 -31510
- package/dist/component.esm.js.map +0 -1
- package/dist/component.js +0 -31517
- package/dist/component.js.map +0 -1
- package/dist/component.min.js.map +0 -1
- package/dist/index.cjs +0 -31811
- package/dist/index.cjs.map +0 -1
- package/dist/index.esm.js +0 -31808
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -31815
- package/dist/index.js.map +0 -1
- package/dist/index.min.js.map +0 -1
- package/dist/meta.esm.js +0 -333
- package/dist/meta.esm.js.map +0 -1
- package/dist/meta.js +0 -343
- package/dist/meta.js.map +0 -1
- package/dist/meta.min.js.map +0 -1
- package/dist/src/component.d.ts +0 -21
- package/dist/src/configure.d.ts +0 -7
- package/dist/src/constants.d.ts +0 -39
- package/dist/src/index.d.ts +0 -6
- package/dist/src/meta.d.ts +0 -3
- package/dist/src/snippets.d.ts +0 -3
- package/rollup.config.js +0 -212
- package/tsconfig.build.json +0 -12
- package/tsconfig.test.json +0 -7
- package/vite.config.ts +0 -54
package/dist/meta.min.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).
|
|
2
|
-
//# sourceMappingURL=meta.min.js.map
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EasyEditorMaterialsRadarChartMeta={})}(this,function(e){"use strict";const t=(e,t)=>{const a=Array.isArray(e)?e:[e],r=a[0]||{};return{sourceType:"static",staticData:a,fieldMappings:Object.keys(r).map(e=>({componentField:e,sourceField:e}))}},a=(e,t,a)=>({type:"group",title:e,setter:{componentName:"CollapseSetter",props:{icon:!1,...a}},items:t}),r={name:"nodeInfo",title:"节点信息",setter:"NodeInfoSetter",extraProps:{label:!1}},i=a("基础配置",[{name:"title",title:"标题",setter:"StringSetter",extraProps:{getValue:e=>e.getExtraPropValue("title"),setValue(e,t){e.setExtraPropValue("title",t)}}},{name:"rect",title:"位置尺寸",setter:"RectSetter",extraProps:{getValue:e=>e.getExtraPropValue("$dashboard.rect"),setValue(e,t){e.setExtraPropValue("$dashboard.rect",t)}}},{name:"rotation",title:"旋转角度",setter:{componentName:"SliderSetter",props:{min:0,max:360,suffix:"°"}},extraProps:{defaultValue:0}},{name:"opacity",title:"不透明度",setter:{componentName:"SliderSetter",props:{min:0,max:100,suffix:"%"}},extraProps:{defaultValue:100}},{name:"background",title:"背景颜色",setter:"ColorSetter",extraProps:{defaultValue:"transparent"}}]),o=[{title:"点击事件",children:[{label:"点击",value:"onClick",description:"鼠标点击时触发"},{label:"双击",value:"onDoubleClick",description:"鼠标双击时触发"}]},{title:"鼠标事件",children:[{label:"鼠标进入",value:"onMouseEnter",description:"鼠标进入时触发"},{label:"鼠标离开",value:"onMouseLeave",description:"鼠标离开时触发"}]}],s=((e=o)=>a("事件绑定",[{name:"events",title:"事件",setter:{componentName:"EventSetter",props:{events:e}},extraProps:{label:!1}}]))(),n=a("高级配置",[{title:"条件渲染",setter:"SwitchSetter",extraProps:{supportVariable:!0,getValue:e=>e.getNode().getExtraPropValue("condition"),setValue(e,t){e.getNode().setExtraProp("condition",t)}}}]),l="EasyEditorMaterialsTechRadarChart";const p=((e,t)=>({props:[{type:"group",title:"属性",setter:"TabSetter",items:[{type:"group",key:"config",title:"配置",items:[r,i,e]},{type:"group",key:"data",title:"数据",items:[r,t]},{type:"group",key:"advanced",title:"高级",items:[r,s,n]}]}],component:{},supports:{},advanced:{}}))(a("组件配置",[{type:"group",title:"组件配置",setter:"SubTabSetter",items:[{type:"group",key:"chartData",title:"数据",items:[{name:"dimensionKey",title:"维度字段",setter:"StringSetter",extraProps:{defaultValue:"dimension"}},{name:"series",title:"系列配置",setter:"JsonSetter"}]},{type:"group",key:"style",title:"样式",items:[{name:"showGrid",title:"显示网格",setter:"SwitchSetter",extraProps:{defaultValue:!0}},{name:"fillOpacity",title:"填充透明度",setter:{componentName:"SliderSetter",props:{min:0,max:1,step:.1}},extraProps:{defaultValue:.3}},{name:"glowEffect",title:"发光效果",setter:"SwitchSetter",extraProps:{defaultValue:!0}}]},{type:"group",key:"legend",title:"图例",items:[{name:"showLegend",title:"显示图例",setter:"SwitchSetter",extraProps:{defaultValue:!0}},{name:"legendPosition",title:"图例位置",setter:{componentName:"SelectSetter",props:{options:[{label:"顶部",value:"top"},{label:"底部",value:"bottom"},{label:"左侧",value:"left"},{label:"右侧",value:"right"}]}},extraProps:{defaultValue:"bottom"}},{name:"showTooltip",title:"显示提示",setter:"SwitchSetter",extraProps:{defaultValue:!0}}]}]}],{padding:"6px 16px 12px"}),{name:"$data",title:"数据配置",setter:{componentName:"DataSetter",props:{expectedFields:[{name:"dimension",label:"dimension",type:"string",required:!0,description:"维度名称"},{name:"value1",label:"value1",type:"number",required:!0,description:"数值1"},{name:"value2",label:"value2",type:"number",required:!1,description:"数值2"}],showPreview:!0,previewLimit:10}},extraProps:{label:!1}});const d={componentName:l,title:"雷达图",group:"chart",devMode:"proCode",npm:{package:"@easy-editor/materials-dashboard-tech-radar-chart",version:"0.0.4",globalName:l,componentName:l},snippets:[{title:"雷达图",screenshot:"",schema:{componentName:l,title:"雷达图",props:{$data:t([{dimension:"销售",series1:80,series2:65},{dimension:"管理",series1:70,series2:85},{dimension:"技术",series1:90,series2:75},{dimension:"客服",series1:75,series2:80},{dimension:"研发",series1:85,series2:70}]),dimensionKey:"dimension",series:[{name:"系列1",dataKey:"series1",color:"#00d4ff"},{name:"系列2",dataKey:"series2",color:"#00ff88"}],showGrid:!0,fillOpacity:.3,glowEffect:!0,showLegend:!0,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:400,height:300}}}},{title:"单系列雷达图",screenshot:"",schema:{componentName:l,title:"单系列雷达图",props:{$data:t([{dimension:"Attack",value:85},{dimension:"Defense",value:70},{dimension:"Speed",value:95},{dimension:"Magic",value:60},{dimension:"HP",value:75}]),dimensionKey:"dimension",series:[{name:"Stats",dataKey:"value",color:"#00d4ff"}],showGrid:!0,fillOpacity:.4,glowEffect:!0,showLegend:!1,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:400,height:300}}}}],configure:p};e.meta=d});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-editor/materials-dashboard-radar-chart",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Radar Chart component for EasyEditor dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,20 +48,16 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"echarts": "^5.6.0",
|
|
51
|
-
"@easy-editor/materials-shared": "0.0.
|
|
51
|
+
"@easy-editor/materials-shared": "0.0.1"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
|
-
"dev": "
|
|
54
|
+
"dev": "easypack dev",
|
|
55
55
|
"dev:debug": "vite --port 5005",
|
|
56
56
|
"format": "biome format --write .",
|
|
57
57
|
"lint": "biome check .",
|
|
58
58
|
"build": "npm-run-all -nl build:*",
|
|
59
59
|
"build:clean": "rimraf dist/",
|
|
60
|
-
"build:js": "
|
|
61
|
-
"build:types": "pnpm types",
|
|
62
|
-
"types": "npm-run-all -nl types:*",
|
|
63
|
-
"types:src": "tsc --project tsconfig.build.json",
|
|
64
|
-
"test-types": "tsc --project tsconfig.test.json"
|
|
60
|
+
"build:js": "easypack build"
|
|
65
61
|
},
|
|
66
62
|
"module": "dist/index.esm.js",
|
|
67
63
|
"unpkg": "dist/index.min.js"
|
package/src/component.tsx
CHANGED
|
@@ -1,199 +1,244 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import type
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Radar Chart Component
|
|
3
|
+
* 雷达图组件 - 支持数据源绑定和事件交互
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useEffect, useMemo, useRef, type CSSProperties } from 'react'
|
|
7
|
+
import * as echarts from 'echarts/core'
|
|
8
|
+
import { RadarChart as EChartsRadarChart } from 'echarts/charts'
|
|
9
|
+
import { TooltipComponent, LegendComponent } from 'echarts/components'
|
|
10
|
+
import { CanvasRenderer } from 'echarts/renderers'
|
|
11
|
+
import type { EChartsOption } from 'echarts'
|
|
12
|
+
import { type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
|
|
13
|
+
import { DEFAULT_DATA, DEFAULT_SERIES, type RadarDataPoint } from './constants'
|
|
14
|
+
import styles from './component.module.css'
|
|
15
|
+
|
|
16
|
+
// 按需注册 ECharts 组件
|
|
17
|
+
echarts.use([EChartsRadarChart, TooltipComponent, LegendComponent, CanvasRenderer])
|
|
18
|
+
|
|
19
|
+
interface RadarSeries {
|
|
20
|
+
name: string
|
|
21
|
+
dataKey: string
|
|
22
|
+
color: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RadarChartProps extends MaterialComponet {
|
|
26
|
+
/** 静态数据(兼容旧版) */
|
|
27
|
+
data?: RadarDataPoint[]
|
|
28
|
+
/** 维度字段 */
|
|
29
|
+
dimensionKey?: string
|
|
30
|
+
/** 系列配置 */
|
|
31
|
+
series?: RadarSeries[]
|
|
32
|
+
/** 显示网格 */
|
|
33
|
+
showGrid?: boolean
|
|
34
|
+
/** 填充透明度 */
|
|
35
|
+
fillOpacity?: number
|
|
36
|
+
/** 发光效果 */
|
|
37
|
+
glowEffect?: boolean
|
|
38
|
+
/** 显示图例 */
|
|
39
|
+
showLegend?: boolean
|
|
40
|
+
/** 显示提示 */
|
|
41
|
+
showTooltip?: boolean
|
|
42
|
+
/** 点击事件 */
|
|
43
|
+
onClick?: (e: React.MouseEvent) => void
|
|
44
|
+
/** 双击事件 */
|
|
45
|
+
onDoubleClick?: (e: React.MouseEvent) => void
|
|
46
|
+
/** 鼠标进入 */
|
|
47
|
+
onMouseEnter?: (e: React.MouseEvent) => void
|
|
48
|
+
/** 鼠标离开 */
|
|
49
|
+
onMouseLeave?: (e: React.MouseEvent) => void
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 构建图表配置
|
|
53
|
+
const buildOption = (
|
|
54
|
+
data: RadarDataPoint[],
|
|
55
|
+
dimensionKey: string,
|
|
56
|
+
series: RadarSeries[],
|
|
57
|
+
options: {
|
|
58
|
+
showGrid: boolean
|
|
59
|
+
fillOpacity: number
|
|
60
|
+
glowEffect: boolean
|
|
61
|
+
showLegend: boolean
|
|
62
|
+
showTooltip: boolean
|
|
63
|
+
},
|
|
64
|
+
): EChartsOption => {
|
|
65
|
+
const { showGrid, fillOpacity, glowEffect, showLegend, showTooltip } = options
|
|
66
|
+
|
|
67
|
+
// 提取维度名称
|
|
68
|
+
const indicators = data.map(item => ({
|
|
69
|
+
name: item[dimensionKey] as string,
|
|
70
|
+
max: 100,
|
|
71
|
+
}))
|
|
72
|
+
|
|
73
|
+
// 构建 series 数据
|
|
74
|
+
const seriesData = series.map(s => ({
|
|
75
|
+
name: s.name,
|
|
76
|
+
value: data.map(item => item[s.dataKey] as number),
|
|
77
|
+
itemStyle: {
|
|
78
|
+
color: s.color,
|
|
79
|
+
shadowColor: glowEffect ? s.color : 'transparent',
|
|
80
|
+
shadowBlur: glowEffect ? 10 : 0,
|
|
81
|
+
},
|
|
82
|
+
lineStyle: {
|
|
83
|
+
color: s.color,
|
|
84
|
+
width: 2,
|
|
85
|
+
shadowColor: glowEffect ? s.color : 'transparent',
|
|
86
|
+
shadowBlur: glowEffect ? 10 : 0,
|
|
87
|
+
},
|
|
88
|
+
areaStyle: {
|
|
89
|
+
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
90
|
+
{
|
|
91
|
+
offset: 0,
|
|
92
|
+
color: `${s.color}${Math.round(fillOpacity * 255)
|
|
93
|
+
.toString(16)
|
|
94
|
+
.padStart(2, '0')}`,
|
|
95
|
+
},
|
|
96
|
+
{ offset: 1, color: `${s.color}10` },
|
|
97
|
+
]),
|
|
98
|
+
},
|
|
99
|
+
}))
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
backgroundColor: 'transparent',
|
|
103
|
+
tooltip: showTooltip
|
|
104
|
+
? {
|
|
105
|
+
trigger: 'item',
|
|
106
|
+
backgroundColor: 'rgba(0, 20, 40, 0.9)',
|
|
107
|
+
borderColor: '#00d4ff',
|
|
108
|
+
borderWidth: 1,
|
|
109
|
+
textStyle: {
|
|
110
|
+
color: '#fff',
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
: undefined,
|
|
114
|
+
legend: showLegend
|
|
115
|
+
? {
|
|
116
|
+
show: true,
|
|
117
|
+
bottom: 10,
|
|
118
|
+
textStyle: {
|
|
119
|
+
color: '#8899aa',
|
|
120
|
+
fontSize: 11,
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
: undefined,
|
|
124
|
+
radar: {
|
|
125
|
+
indicator: indicators,
|
|
126
|
+
shape: 'polygon',
|
|
127
|
+
splitNumber: 5,
|
|
128
|
+
axisName: {
|
|
129
|
+
color: '#8899aa',
|
|
130
|
+
fontSize: 11,
|
|
131
|
+
},
|
|
132
|
+
splitLine: {
|
|
133
|
+
show: showGrid,
|
|
134
|
+
lineStyle: {
|
|
135
|
+
color: '#1a3a5c',
|
|
136
|
+
opacity: 0.6,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
splitArea: {
|
|
140
|
+
show: false,
|
|
141
|
+
},
|
|
142
|
+
axisLine: {
|
|
143
|
+
show: showGrid,
|
|
144
|
+
lineStyle: {
|
|
145
|
+
color: '#1a3a5c',
|
|
146
|
+
opacity: 0.6,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
series: [
|
|
151
|
+
{
|
|
152
|
+
type: 'radar',
|
|
153
|
+
data: seriesData,
|
|
154
|
+
symbol: 'circle',
|
|
155
|
+
symbolSize: 6,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const RadarChart: React.FC<RadarChartProps> = ({
|
|
162
|
+
ref,
|
|
163
|
+
$data,
|
|
164
|
+
__dataSource,
|
|
165
|
+
data: staticData,
|
|
166
|
+
dimensionKey = 'dimension',
|
|
167
|
+
series = DEFAULT_SERIES,
|
|
168
|
+
showGrid = true,
|
|
169
|
+
fillOpacity = 0.3,
|
|
170
|
+
glowEffect = true,
|
|
171
|
+
showLegend = true,
|
|
172
|
+
showTooltip = true,
|
|
173
|
+
rotation = 0,
|
|
174
|
+
opacity = 100,
|
|
175
|
+
background = 'transparent',
|
|
176
|
+
style: externalStyle,
|
|
177
|
+
onClick,
|
|
178
|
+
onDoubleClick,
|
|
179
|
+
onMouseEnter,
|
|
180
|
+
onMouseLeave,
|
|
181
|
+
}) => {
|
|
182
|
+
const chartRef = useRef<HTMLDivElement>(null)
|
|
183
|
+
const chartInstance = useRef<echarts.ECharts | null>(null)
|
|
184
|
+
|
|
185
|
+
// 解析数据源
|
|
186
|
+
const dataSource = useDataSource($data, __dataSource)
|
|
187
|
+
const data = useMemo<RadarDataPoint[]>(() => {
|
|
188
|
+
if (dataSource.length > 0) {
|
|
189
|
+
return dataSource as RadarDataPoint[]
|
|
190
|
+
}
|
|
191
|
+
return staticData ?? DEFAULT_DATA
|
|
192
|
+
}, [dataSource, staticData])
|
|
193
|
+
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!chartRef.current) {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
chartInstance.current = echarts.init(chartRef.current)
|
|
200
|
+
|
|
201
|
+
const option = buildOption(data, dimensionKey, series, {
|
|
202
|
+
showGrid,
|
|
203
|
+
fillOpacity,
|
|
204
|
+
glowEffect,
|
|
205
|
+
showLegend,
|
|
206
|
+
showTooltip,
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
chartInstance.current.setOption(option)
|
|
210
|
+
|
|
211
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
212
|
+
chartInstance.current?.resize()
|
|
213
|
+
})
|
|
214
|
+
resizeObserver.observe(chartRef.current)
|
|
215
|
+
|
|
216
|
+
return () => {
|
|
217
|
+
resizeObserver.disconnect()
|
|
218
|
+
chartInstance.current?.dispose()
|
|
219
|
+
}
|
|
220
|
+
}, [data, dimensionKey, series, showGrid, fillOpacity, glowEffect, showLegend, showTooltip])
|
|
221
|
+
|
|
222
|
+
const containerStyle: CSSProperties = {
|
|
223
|
+
width: '100%',
|
|
224
|
+
height: '100%',
|
|
225
|
+
transform: rotation !== 0 ? `rotate(${rotation}deg)` : undefined,
|
|
226
|
+
opacity: opacity / 100,
|
|
227
|
+
backgroundColor: background,
|
|
228
|
+
...externalStyle,
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<div
|
|
233
|
+
className={styles.container}
|
|
234
|
+
onClick={onClick}
|
|
235
|
+
onDoubleClick={onDoubleClick}
|
|
236
|
+
onMouseEnter={onMouseEnter}
|
|
237
|
+
onMouseLeave={onMouseLeave}
|
|
238
|
+
ref={ref}
|
|
239
|
+
style={containerStyle}
|
|
240
|
+
>
|
|
241
|
+
<div className={styles.chart} ref={chartRef} />
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|