@easy-editor/materials-dashboard-radar-chart 0.0.2

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.
Files changed (44) hide show
  1. package/.vite/plugins/vite-plugin-external-deps.ts +224 -0
  2. package/.vite/plugins/vite-plugin-material-dev.ts +218 -0
  3. package/CHANGELOG.md +7 -0
  4. package/LICENSE +9 -0
  5. package/dist/component.esm.js +31510 -0
  6. package/dist/component.esm.js.map +1 -0
  7. package/dist/component.js +31517 -0
  8. package/dist/component.js.map +1 -0
  9. package/dist/component.min.js +24 -0
  10. package/dist/component.min.js.map +1 -0
  11. package/dist/index.cjs +31811 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.esm.js +31808 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.js +31815 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.min.js +24 -0
  18. package/dist/index.min.js.map +1 -0
  19. package/dist/meta.esm.js +333 -0
  20. package/dist/meta.esm.js.map +1 -0
  21. package/dist/meta.js +343 -0
  22. package/dist/meta.js.map +1 -0
  23. package/dist/meta.min.js +2 -0
  24. package/dist/meta.min.js.map +1 -0
  25. package/dist/src/component.d.ts +21 -0
  26. package/dist/src/configure.d.ts +7 -0
  27. package/dist/src/constants.d.ts +39 -0
  28. package/dist/src/index.d.ts +6 -0
  29. package/dist/src/meta.d.ts +3 -0
  30. package/dist/src/snippets.d.ts +3 -0
  31. package/package.json +68 -0
  32. package/rollup.config.js +212 -0
  33. package/src/component.module.css +16 -0
  34. package/src/component.tsx +199 -0
  35. package/src/configure.ts +247 -0
  36. package/src/constants.ts +51 -0
  37. package/src/index.tsx +7 -0
  38. package/src/meta.ts +23 -0
  39. package/src/snippets.ts +57 -0
  40. package/src/type.d.ts +8 -0
  41. package/tsconfig.build.json +12 -0
  42. package/tsconfig.json +9 -0
  43. package/tsconfig.test.json +7 -0
  44. package/vite.config.ts +54 -0
@@ -0,0 +1,212 @@
1
+ import babel from '@rollup/plugin-babel'
2
+ import commonjs from '@rollup/plugin-commonjs'
3
+ import nodeResolve from '@rollup/plugin-node-resolve'
4
+ import json from '@rollup/plugin-json'
5
+ import { terser } from 'rollup-plugin-terser'
6
+ import cleanup from 'rollup-plugin-cleanup'
7
+ import postcss from 'rollup-plugin-postcss'
8
+ import pkg from './package.json' with { type: 'json' }
9
+
10
+ const GLOBAL_NAME = 'EasyEditorMaterialsTechRadarChart'
11
+
12
+ // 外部依赖(不打包进组件)
13
+ const external = ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core']
14
+
15
+ const globals = {
16
+ react: 'React',
17
+ 'react-dom': 'ReactDOM',
18
+ 'react/jsx-runtime': 'jsxRuntime',
19
+ '@easy-editor/core': 'EasyEditorCore',
20
+ }
21
+
22
+ const plugins = [
23
+ nodeResolve({
24
+ extensions: ['.js', '.ts', '.jsx', '.tsx'],
25
+ }),
26
+ commonjs(),
27
+ json(),
28
+ postcss({
29
+ modules: {
30
+ generateScopedName: '[name]__[local]___[hash:base64:5]',
31
+ },
32
+ autoModules: true,
33
+ minimize: true,
34
+ inject: true,
35
+ }),
36
+ babel({
37
+ extensions: ['.js', '.ts', '.jsx', '.tsx'],
38
+ exclude: 'node_modules/**',
39
+ babelrc: false,
40
+ babelHelpers: 'bundled',
41
+ presets: [
42
+ ['@babel/preset-react', { runtime: 'automatic' }],
43
+ [
44
+ '@babel/preset-typescript',
45
+ {
46
+ allowDeclareFields: true,
47
+ },
48
+ ],
49
+ ],
50
+ }),
51
+ cleanup({
52
+ comments: ['some', /PURE/],
53
+ extensions: ['.js', '.ts'],
54
+ }),
55
+ ]
56
+
57
+ export default [
58
+ /* ---------------------------------- 元数据构建 --------------------------------- */
59
+ {
60
+ input: 'src/meta.ts',
61
+ output: [
62
+ {
63
+ file: 'dist/meta.esm.js',
64
+ format: 'esm',
65
+ sourcemap: true,
66
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (meta, esm) */`,
67
+ exports: 'named',
68
+ },
69
+ ],
70
+ plugins,
71
+ external,
72
+ },
73
+ {
74
+ input: 'src/meta.ts',
75
+ output: [
76
+ {
77
+ file: 'dist/meta.js',
78
+ format: 'umd',
79
+ name: `${GLOBAL_NAME}Meta`,
80
+ globals,
81
+ sourcemap: true,
82
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (meta) */`,
83
+ exports: 'named',
84
+ },
85
+ ],
86
+ plugins,
87
+ external,
88
+ },
89
+ {
90
+ input: 'src/meta.ts',
91
+ output: [
92
+ {
93
+ file: 'dist/meta.min.js',
94
+ format: 'umd',
95
+ name: `${GLOBAL_NAME}Meta`,
96
+ globals,
97
+ sourcemap: true,
98
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (meta, minified) */`,
99
+ exports: 'named',
100
+ },
101
+ ],
102
+ plugins: [...plugins, terser()],
103
+ external,
104
+ },
105
+
106
+ /* ---------------------------------- 组件构建 ---------------------------------- */
107
+ {
108
+ input: 'src/component.tsx',
109
+ output: [
110
+ {
111
+ file: 'dist/component.esm.js',
112
+ format: 'esm',
113
+ sourcemap: true,
114
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (component, esm) */`,
115
+ exports: 'named',
116
+ },
117
+ ],
118
+ plugins,
119
+ external,
120
+ },
121
+ {
122
+ input: 'src/component.tsx',
123
+ output: [
124
+ {
125
+ file: 'dist/component.js',
126
+ format: 'umd',
127
+ name: `${GLOBAL_NAME}Component`,
128
+ globals,
129
+ sourcemap: true,
130
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (component) */`,
131
+ exports: 'named',
132
+ },
133
+ ],
134
+ plugins,
135
+ external,
136
+ },
137
+ {
138
+ input: 'src/component.tsx',
139
+ output: [
140
+ {
141
+ file: 'dist/component.min.js',
142
+ format: 'umd',
143
+ name: `${GLOBAL_NAME}Component`,
144
+ globals,
145
+ sourcemap: true,
146
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (component, minified) */`,
147
+ exports: 'named',
148
+ },
149
+ ],
150
+ plugins: [...plugins, terser()],
151
+ external,
152
+ },
153
+
154
+ /* ---------------------------------- 完整构建 ---------------------------------- */
155
+ {
156
+ input: 'src/index.tsx',
157
+ output: [
158
+ {
159
+ file: 'dist/index.js',
160
+ format: 'umd',
161
+ name: GLOBAL_NAME,
162
+ globals,
163
+ sourcemap: true,
164
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} */`,
165
+ exports: 'named',
166
+ },
167
+ ],
168
+ plugins,
169
+ external,
170
+ },
171
+ {
172
+ input: 'src/index.tsx',
173
+ output: [
174
+ {
175
+ file: 'dist/index.esm.js',
176
+ format: 'esm',
177
+ sourcemap: true,
178
+ },
179
+ ],
180
+ plugins,
181
+ external,
182
+ },
183
+ {
184
+ input: 'src/index.tsx',
185
+ output: [
186
+ {
187
+ file: 'dist/index.cjs',
188
+ format: 'cjs',
189
+ sourcemap: true,
190
+ exports: 'named',
191
+ },
192
+ ],
193
+ plugins,
194
+ external,
195
+ },
196
+ {
197
+ input: 'src/index.tsx',
198
+ output: [
199
+ {
200
+ file: 'dist/index.min.js',
201
+ format: 'umd',
202
+ name: GLOBAL_NAME,
203
+ globals,
204
+ sourcemap: true,
205
+ banner: `/* @easy-editor/materials-dashboard-tech-radar-chart v${pkg.version} (minified) */`,
206
+ exports: 'named',
207
+ },
208
+ ],
209
+ plugins: [...plugins, terser()],
210
+ external,
211
+ },
212
+ ]
@@ -0,0 +1,16 @@
1
+ .container {
2
+ width: 100%;
3
+ height: 100%;
4
+ background: linear-gradient(
5
+ 180deg,
6
+ rgba(0, 20, 40, 0.9) 0%,
7
+ rgba(0, 10, 20, 0.95) 100%
8
+ );
9
+ border-radius: 8px;
10
+ overflow: hidden;
11
+ }
12
+
13
+ .chart {
14
+ width: 100%;
15
+ height: 100%;
16
+ }
@@ -0,0 +1,199 @@
1
+ import { useEffect, useRef, type CSSProperties, type Ref } from 'react'
2
+ import * as echarts from 'echarts/core'
3
+ import { RadarChart } from 'echarts/charts'
4
+ import { TooltipComponent, LegendComponent } from 'echarts/components'
5
+ import { CanvasRenderer } from 'echarts/renderers'
6
+ import type { EChartsOption } from 'echarts'
7
+ import { DEFAULT_DATA, DEFAULT_SERIES, type RadarDataPoint } from './constants'
8
+ import styles from './component.module.css'
9
+
10
+ // 按需注册 ECharts 组件
11
+ echarts.use([RadarChart, TooltipComponent, LegendComponent, CanvasRenderer])
12
+
13
+ interface RadarSeries {
14
+ name: string
15
+ dataKey: string
16
+ color: string
17
+ }
18
+
19
+ interface RadarChartProps {
20
+ ref?: Ref<HTMLDivElement>
21
+ data?: RadarDataPoint[]
22
+ dimensionKey?: string
23
+ series?: RadarSeries[]
24
+ showGrid?: boolean
25
+ fillOpacity?: number
26
+ glowEffect?: boolean
27
+ showLegend?: boolean
28
+ showTooltip?: boolean
29
+ style?: CSSProperties
30
+ }
31
+
32
+ // 构建图表配置
33
+ const buildOption = (
34
+ data: RadarDataPoint[],
35
+ dimensionKey: string,
36
+ series: RadarSeries[],
37
+ options: {
38
+ showGrid: boolean
39
+ fillOpacity: number
40
+ glowEffect: boolean
41
+ showLegend: boolean
42
+ showTooltip: boolean
43
+ },
44
+ ): EChartsOption => {
45
+ const { showGrid, fillOpacity, glowEffect, showLegend, showTooltip } = options
46
+
47
+ // 提取维度名称
48
+ const indicators = data.map(item => ({
49
+ name: item[dimensionKey] as string,
50
+ max: 100,
51
+ }))
52
+
53
+ // 构建 series 数据
54
+ const seriesData = series.map(s => ({
55
+ name: s.name,
56
+ value: data.map(item => item[s.dataKey] as number),
57
+ itemStyle: {
58
+ color: s.color,
59
+ shadowColor: glowEffect ? s.color : 'transparent',
60
+ shadowBlur: glowEffect ? 10 : 0,
61
+ },
62
+ lineStyle: {
63
+ color: s.color,
64
+ width: 2,
65
+ shadowColor: glowEffect ? s.color : 'transparent',
66
+ shadowBlur: glowEffect ? 10 : 0,
67
+ },
68
+ areaStyle: {
69
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
70
+ {
71
+ offset: 0,
72
+ color: `${s.color}${Math.round(fillOpacity * 255)
73
+ .toString(16)
74
+ .padStart(2, '0')}`,
75
+ },
76
+ { offset: 1, color: `${s.color}10` },
77
+ ]),
78
+ },
79
+ }))
80
+
81
+ return {
82
+ backgroundColor: 'transparent',
83
+ tooltip: showTooltip
84
+ ? {
85
+ trigger: 'item',
86
+ backgroundColor: 'rgba(0, 20, 40, 0.9)',
87
+ borderColor: '#00d4ff',
88
+ borderWidth: 1,
89
+ textStyle: {
90
+ color: '#fff',
91
+ },
92
+ }
93
+ : undefined,
94
+ legend: showLegend
95
+ ? {
96
+ show: true,
97
+ bottom: 10,
98
+ textStyle: {
99
+ color: '#8899aa',
100
+ fontSize: 11,
101
+ },
102
+ }
103
+ : undefined,
104
+ radar: {
105
+ indicator: indicators,
106
+ shape: 'polygon',
107
+ splitNumber: 5,
108
+ axisName: {
109
+ color: '#8899aa',
110
+ fontSize: 11,
111
+ },
112
+ splitLine: {
113
+ show: showGrid,
114
+ lineStyle: {
115
+ color: '#1a3a5c',
116
+ opacity: 0.6,
117
+ },
118
+ },
119
+ splitArea: {
120
+ show: false,
121
+ },
122
+ axisLine: {
123
+ show: showGrid,
124
+ lineStyle: {
125
+ color: '#1a3a5c',
126
+ opacity: 0.6,
127
+ },
128
+ },
129
+ },
130
+ series: [
131
+ {
132
+ type: 'radar',
133
+ data: seriesData,
134
+ symbol: 'circle',
135
+ symbolSize: 6,
136
+ },
137
+ ],
138
+ }
139
+ }
140
+
141
+ const RadarChartComponent = (props: RadarChartProps) => {
142
+ const {
143
+ ref,
144
+ data = DEFAULT_DATA,
145
+ dimensionKey = 'dimension',
146
+ series = DEFAULT_SERIES,
147
+ showGrid = true,
148
+ fillOpacity = 0.3,
149
+ glowEffect = true,
150
+ showLegend = true,
151
+ showTooltip = true,
152
+ style: externalStyle,
153
+ } = props
154
+
155
+ const chartRef = useRef<HTMLDivElement>(null)
156
+ const chartInstance = useRef<echarts.ECharts | null>(null)
157
+
158
+ useEffect(() => {
159
+ if (!chartRef.current) {
160
+ return
161
+ }
162
+
163
+ chartInstance.current = echarts.init(chartRef.current)
164
+
165
+ const option = buildOption(data, dimensionKey, series, {
166
+ showGrid,
167
+ fillOpacity,
168
+ glowEffect,
169
+ showLegend,
170
+ showTooltip,
171
+ })
172
+
173
+ chartInstance.current.setOption(option)
174
+
175
+ const resizeObserver = new ResizeObserver(() => {
176
+ chartInstance.current?.resize()
177
+ })
178
+ resizeObserver.observe(chartRef.current)
179
+
180
+ return () => {
181
+ resizeObserver.disconnect()
182
+ chartInstance.current?.dispose()
183
+ }
184
+ }, [data, dimensionKey, series, showGrid, fillOpacity, glowEffect, showLegend, showTooltip])
185
+
186
+ const containerStyle: CSSProperties = {
187
+ width: '100%',
188
+ height: '100%',
189
+ ...externalStyle,
190
+ }
191
+
192
+ return (
193
+ <div className={styles.container} ref={ref} style={containerStyle}>
194
+ <div className={styles.chart} ref={chartRef} />
195
+ </div>
196
+ )
197
+ }
198
+
199
+ export default RadarChartComponent
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Radar Chart Configure
3
+ * 雷达图组件配置
4
+ */
5
+
6
+ import type { Configure } from '@easy-editor/core'
7
+
8
+ const configure: Configure = {
9
+ props: [
10
+ {
11
+ type: 'group',
12
+ title: '属性',
13
+ setter: 'TabSetter',
14
+ items: [
15
+ {
16
+ type: 'group',
17
+ key: 'config',
18
+ title: '配置',
19
+ setter: {
20
+ componentName: 'CollapseSetter',
21
+ props: {
22
+ icon: false,
23
+ },
24
+ },
25
+ items: [
26
+ // 基础配置
27
+ {
28
+ name: 'id',
29
+ title: 'ID',
30
+ setter: 'NodeIdSetter',
31
+ extraProps: {
32
+ // @ts-expect-error label is not a valid extra prop
33
+ label: false,
34
+ },
35
+ },
36
+ {
37
+ name: 'title',
38
+ title: '标题',
39
+ setter: 'StringSetter',
40
+ extraProps: {
41
+ getValue(target) {
42
+ return target.getExtraPropValue('title')
43
+ },
44
+ setValue(target, value) {
45
+ target.setExtraPropValue('title', value)
46
+ },
47
+ },
48
+ },
49
+ {
50
+ type: 'group',
51
+ title: '基础属性',
52
+ setter: {
53
+ componentName: 'CollapseSetter',
54
+ props: {
55
+ icon: false,
56
+ },
57
+ },
58
+ items: [
59
+ {
60
+ name: 'rect',
61
+ title: '位置尺寸',
62
+ setter: 'RectSetter',
63
+ extraProps: {
64
+ getValue(target) {
65
+ return target.getExtraPropValue('$dashboard.rect')
66
+ },
67
+ setValue(target, value) {
68
+ target.setExtraPropValue('$dashboard.rect', value)
69
+ },
70
+ },
71
+ },
72
+ ],
73
+ },
74
+ // 组件配置
75
+ {
76
+ type: 'group',
77
+ title: '数据',
78
+ setter: {
79
+ componentName: 'CollapseSetter',
80
+ props: {
81
+ icon: false,
82
+ },
83
+ },
84
+ items: [
85
+ {
86
+ name: 'data',
87
+ title: '数据',
88
+ setter: 'JsonSetter',
89
+ },
90
+ {
91
+ name: 'dimensionKey',
92
+ title: '维度字段',
93
+ setter: 'StringSetter',
94
+ extraProps: {
95
+ defaultValue: 'dimension',
96
+ },
97
+ },
98
+ {
99
+ name: 'series',
100
+ title: '系列',
101
+ setter: 'JsonSetter',
102
+ },
103
+ ],
104
+ },
105
+ {
106
+ type: 'group',
107
+ title: '数值格式',
108
+ setter: {
109
+ componentName: 'CollapseSetter',
110
+ props: {
111
+ icon: false,
112
+ },
113
+ },
114
+ items: [
115
+ {
116
+ name: 'valuePrefix',
117
+ title: '前缀',
118
+ setter: 'StringSetter',
119
+ },
120
+ {
121
+ name: 'valueSuffix',
122
+ title: '后缀',
123
+ setter: 'StringSetter',
124
+ },
125
+ {
126
+ name: 'valueDecimals',
127
+ title: '小数位数',
128
+ setter: {
129
+ componentName: 'NumberSetter',
130
+ props: {
131
+ suffix: '位',
132
+ },
133
+ },
134
+ extraProps: {
135
+ defaultValue: 0,
136
+ },
137
+ },
138
+ ],
139
+ },
140
+ {
141
+ type: 'group',
142
+ title: '样式',
143
+ setter: {
144
+ componentName: 'CollapseSetter',
145
+ props: {
146
+ icon: false,
147
+ },
148
+ },
149
+ items: [
150
+ {
151
+ name: 'showGrid',
152
+ title: '显示网格',
153
+ setter: 'SwitchSetter',
154
+ extraProps: {
155
+ defaultValue: true,
156
+ },
157
+ },
158
+ {
159
+ name: 'fillOpacity',
160
+ title: '填充透明度',
161
+ setter: {
162
+ componentName: 'SliderSetter',
163
+ props: {
164
+ min: 0,
165
+ max: 1,
166
+ step: 0.1,
167
+ },
168
+ },
169
+ extraProps: {
170
+ defaultValue: 0.3,
171
+ },
172
+ },
173
+ {
174
+ name: 'showLegend',
175
+ title: '显示图例',
176
+ setter: 'SwitchSetter',
177
+ extraProps: {
178
+ defaultValue: true,
179
+ },
180
+ },
181
+ {
182
+ name: 'legendPosition',
183
+ title: '图例位置',
184
+ setter: {
185
+ componentName: 'SelectSetter',
186
+ props: {
187
+ options: [
188
+ { label: '顶部', value: 'top' },
189
+ { label: '底部', value: 'bottom' },
190
+ { label: '左侧', value: 'left' },
191
+ { label: '右侧', value: 'right' },
192
+ ],
193
+ },
194
+ },
195
+ extraProps: {
196
+ defaultValue: 'bottom',
197
+ },
198
+ },
199
+ {
200
+ name: 'glowEffect',
201
+ title: '发光效果',
202
+ setter: 'SwitchSetter',
203
+ extraProps: {
204
+ defaultValue: true,
205
+ },
206
+ },
207
+ ],
208
+ },
209
+ ],
210
+ },
211
+ {
212
+ type: 'group',
213
+ key: 'data',
214
+ title: '数据',
215
+ items: [
216
+ {
217
+ name: 'dataBinding',
218
+ title: '数据绑定',
219
+ setter: 'DataBindingSetter',
220
+ },
221
+ ],
222
+ },
223
+ {
224
+ type: 'group',
225
+ key: 'advanced',
226
+ title: '高级',
227
+ items: [
228
+ {
229
+ name: 'condition',
230
+ title: '显隐控制',
231
+ setter: 'SwitchSetter',
232
+ extraProps: {
233
+ defaultValue: true,
234
+ supportVariable: true,
235
+ },
236
+ },
237
+ ],
238
+ },
239
+ ],
240
+ },
241
+ ],
242
+ component: {},
243
+ supports: {},
244
+ advanced: {},
245
+ }
246
+
247
+ export default configure