@easy-editor/materials-dashboard-geo-map 0.0.3 → 0.0.5
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/.vite/echarts-external-plugin.ts +61 -0
- package/CHANGELOG.md +27 -15
- package/dist/component.min.js +1 -23
- package/dist/index.min.js +1 -23
- package/dist/meta.min.js +1 -1
- package/easypack.config.ts +9 -0
- package/package.json +1 -1
- package/src/component.tsx +323 -325
- package/src/meta.ts +23 -23
package/src/component.tsx
CHANGED
|
@@ -1,325 +1,323 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Geo Map Component
|
|
3
|
-
* 地理地图组件 - 支持数据源绑定和事件交互
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useEffect, useRef, useMemo, type CSSProperties } from 'react'
|
|
7
|
-
import * as echarts from 'echarts/core'
|
|
8
|
-
import { MapChart, EffectScatterChart } from 'echarts/charts'
|
|
9
|
-
import { GeoComponent, TooltipComponent, VisualMapComponent } from 'echarts/components'
|
|
10
|
-
import { CanvasRenderer } from 'echarts/renderers'
|
|
11
|
-
import { type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
|
|
12
|
-
import {
|
|
13
|
-
DEFAULT_COLORS,
|
|
14
|
-
DEFAULT_REGION_DATA,
|
|
15
|
-
DEFAULT_SCATTER_DATA,
|
|
16
|
-
type MapDataPoint,
|
|
17
|
-
type ScatterPoint,
|
|
18
|
-
type MapType,
|
|
19
|
-
} from './constants'
|
|
20
|
-
import chinaGeoJson from './assets/geo/china.json'
|
|
21
|
-
import worldGeoJson from './assets/geo/world.json'
|
|
22
|
-
import styles from './component.module.css'
|
|
23
|
-
|
|
24
|
-
// 按需注册 ECharts 组件
|
|
25
|
-
echarts.use([MapChart, EffectScatterChart, GeoComponent, TooltipComponent, VisualMapComponent, CanvasRenderer])
|
|
26
|
-
|
|
27
|
-
// 内置地图数据
|
|
28
|
-
const BUILTIN_MAP_JSON: Record<MapType, object> = {
|
|
29
|
-
china: chinaGeoJson as object,
|
|
30
|
-
world: worldGeoJson as object,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 已注册的地图
|
|
34
|
-
const registeredMaps = new Set<string>()
|
|
35
|
-
|
|
36
|
-
interface GeoMapProps extends MaterialComponet {
|
|
37
|
-
/** 地图类型 */
|
|
38
|
-
mapType?: MapType
|
|
39
|
-
/** 地图 GeoJSON 数据 */
|
|
40
|
-
mapJson?: object
|
|
41
|
-
/** 区域数据(兼容旧版) */
|
|
42
|
-
regionData?: MapDataPoint[]
|
|
43
|
-
/** 散点数据(兼容旧版) */
|
|
44
|
-
scatterData?: ScatterPoint[]
|
|
45
|
-
/** 颜色列表 */
|
|
46
|
-
colors?: string[]
|
|
47
|
-
/** 显示图例 */
|
|
48
|
-
showVisualMap?: boolean
|
|
49
|
-
/** 显示提示 */
|
|
50
|
-
showTooltip?: boolean
|
|
51
|
-
/** 显示散点 */
|
|
52
|
-
showScatter?: boolean
|
|
53
|
-
/** 散点大小 */
|
|
54
|
-
scatterSymbolSize?: number
|
|
55
|
-
/** 发光效果 */
|
|
56
|
-
glowEffect?: boolean
|
|
57
|
-
/** 允许缩放 */
|
|
58
|
-
roam?: boolean
|
|
59
|
-
/** 点击事件 */
|
|
60
|
-
onClick?: (e: React.MouseEvent) => void
|
|
61
|
-
/** 双击事件 */
|
|
62
|
-
onDoubleClick?: (e: React.MouseEvent) => void
|
|
63
|
-
/** 鼠标进入 */
|
|
64
|
-
onMouseEnter?: (e: React.MouseEvent) => void
|
|
65
|
-
/** 鼠标离开 */
|
|
66
|
-
onMouseLeave?: (e: React.MouseEvent) => void
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const GeoMap = (props: GeoMapProps) => {
|
|
70
|
-
const {
|
|
71
|
-
ref,
|
|
72
|
-
$data,
|
|
73
|
-
__dataSource,
|
|
74
|
-
mapType = 'china',
|
|
75
|
-
mapJson,
|
|
76
|
-
regionData: staticRegionData,
|
|
77
|
-
scatterData: staticScatterData,
|
|
78
|
-
colors,
|
|
79
|
-
showVisualMap = true,
|
|
80
|
-
showTooltip = true,
|
|
81
|
-
showScatter = true,
|
|
82
|
-
scatterSymbolSize = 12,
|
|
83
|
-
glowEffect = true,
|
|
84
|
-
roam = true,
|
|
85
|
-
rotation = 0,
|
|
86
|
-
opacity = 100,
|
|
87
|
-
background = 'transparent',
|
|
88
|
-
style: externalStyle,
|
|
89
|
-
onClick,
|
|
90
|
-
onDoubleClick,
|
|
91
|
-
onMouseEnter,
|
|
92
|
-
onMouseLeave,
|
|
93
|
-
} = props
|
|
94
|
-
|
|
95
|
-
// 解析数据源
|
|
96
|
-
const dataSource = useDataSource($data, __dataSource)
|
|
97
|
-
const regionData = useMemo<MapDataPoint[]>(() => {
|
|
98
|
-
if (dataSource.length > 0) {
|
|
99
|
-
return dataSource as MapDataPoint[]
|
|
100
|
-
}
|
|
101
|
-
return staticRegionData ?? DEFAULT_REGION_DATA
|
|
102
|
-
}, [dataSource, staticRegionData])
|
|
103
|
-
const scatterData = useMemo<ScatterPoint[]>(() =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
const
|
|
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
|
-
color: '
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
)
|
|
325
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Geo Map Component
|
|
3
|
+
* 地理地图组件 - 支持数据源绑定和事件交互
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useEffect, useRef, useMemo, type CSSProperties } from 'react'
|
|
7
|
+
import * as echarts from 'echarts/core'
|
|
8
|
+
import { MapChart, EffectScatterChart } from 'echarts/charts'
|
|
9
|
+
import { GeoComponent, TooltipComponent, VisualMapComponent } from 'echarts/components'
|
|
10
|
+
import { CanvasRenderer } from 'echarts/renderers'
|
|
11
|
+
import { type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_COLORS,
|
|
14
|
+
DEFAULT_REGION_DATA,
|
|
15
|
+
DEFAULT_SCATTER_DATA,
|
|
16
|
+
type MapDataPoint,
|
|
17
|
+
type ScatterPoint,
|
|
18
|
+
type MapType,
|
|
19
|
+
} from './constants'
|
|
20
|
+
import chinaGeoJson from './assets/geo/china.json'
|
|
21
|
+
import worldGeoJson from './assets/geo/world.json'
|
|
22
|
+
import styles from './component.module.css'
|
|
23
|
+
|
|
24
|
+
// 按需注册 ECharts 组件
|
|
25
|
+
echarts.use([MapChart, EffectScatterChart, GeoComponent, TooltipComponent, VisualMapComponent, CanvasRenderer])
|
|
26
|
+
|
|
27
|
+
// 内置地图数据
|
|
28
|
+
const BUILTIN_MAP_JSON: Record<MapType, object> = {
|
|
29
|
+
china: chinaGeoJson as object,
|
|
30
|
+
world: worldGeoJson as object,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 已注册的地图
|
|
34
|
+
const registeredMaps = new Set<string>()
|
|
35
|
+
|
|
36
|
+
interface GeoMapProps extends MaterialComponet {
|
|
37
|
+
/** 地图类型 */
|
|
38
|
+
mapType?: MapType
|
|
39
|
+
/** 地图 GeoJSON 数据 */
|
|
40
|
+
mapJson?: object
|
|
41
|
+
/** 区域数据(兼容旧版) */
|
|
42
|
+
regionData?: MapDataPoint[]
|
|
43
|
+
/** 散点数据(兼容旧版) */
|
|
44
|
+
scatterData?: ScatterPoint[]
|
|
45
|
+
/** 颜色列表 */
|
|
46
|
+
colors?: string[]
|
|
47
|
+
/** 显示图例 */
|
|
48
|
+
showVisualMap?: boolean
|
|
49
|
+
/** 显示提示 */
|
|
50
|
+
showTooltip?: boolean
|
|
51
|
+
/** 显示散点 */
|
|
52
|
+
showScatter?: boolean
|
|
53
|
+
/** 散点大小 */
|
|
54
|
+
scatterSymbolSize?: number
|
|
55
|
+
/** 发光效果 */
|
|
56
|
+
glowEffect?: boolean
|
|
57
|
+
/** 允许缩放 */
|
|
58
|
+
roam?: boolean
|
|
59
|
+
/** 点击事件 */
|
|
60
|
+
onClick?: (e: React.MouseEvent) => void
|
|
61
|
+
/** 双击事件 */
|
|
62
|
+
onDoubleClick?: (e: React.MouseEvent) => void
|
|
63
|
+
/** 鼠标进入 */
|
|
64
|
+
onMouseEnter?: (e: React.MouseEvent) => void
|
|
65
|
+
/** 鼠标离开 */
|
|
66
|
+
onMouseLeave?: (e: React.MouseEvent) => void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const GeoMap = (props: GeoMapProps) => {
|
|
70
|
+
const {
|
|
71
|
+
ref,
|
|
72
|
+
$data,
|
|
73
|
+
__dataSource,
|
|
74
|
+
mapType = 'china',
|
|
75
|
+
mapJson,
|
|
76
|
+
regionData: staticRegionData,
|
|
77
|
+
scatterData: staticScatterData,
|
|
78
|
+
colors,
|
|
79
|
+
showVisualMap = true,
|
|
80
|
+
showTooltip = true,
|
|
81
|
+
showScatter = true,
|
|
82
|
+
scatterSymbolSize = 12,
|
|
83
|
+
glowEffect = true,
|
|
84
|
+
roam = true,
|
|
85
|
+
rotation = 0,
|
|
86
|
+
opacity = 100,
|
|
87
|
+
background = 'transparent',
|
|
88
|
+
style: externalStyle,
|
|
89
|
+
onClick,
|
|
90
|
+
onDoubleClick,
|
|
91
|
+
onMouseEnter,
|
|
92
|
+
onMouseLeave,
|
|
93
|
+
} = props
|
|
94
|
+
|
|
95
|
+
// 解析数据源
|
|
96
|
+
const dataSource = useDataSource($data, __dataSource)
|
|
97
|
+
const regionData = useMemo<MapDataPoint[]>(() => {
|
|
98
|
+
if (dataSource.length > 0) {
|
|
99
|
+
return dataSource as MapDataPoint[]
|
|
100
|
+
}
|
|
101
|
+
return staticRegionData ?? DEFAULT_REGION_DATA
|
|
102
|
+
}, [dataSource, staticRegionData])
|
|
103
|
+
const scatterData = useMemo<ScatterPoint[]>(() => staticScatterData ?? DEFAULT_SCATTER_DATA, [staticScatterData])
|
|
104
|
+
const chartColors = useMemo<string[]>(() => colors ?? DEFAULT_COLORS, [colors])
|
|
105
|
+
|
|
106
|
+
const chartRef = useRef<HTMLDivElement>(null)
|
|
107
|
+
const chartInstance = useRef<echarts.ECharts | null>(null)
|
|
108
|
+
|
|
109
|
+
// 计算数据范围
|
|
110
|
+
const values = regionData.map(d => d.value)
|
|
111
|
+
const minValue = values.length > 0 ? Math.min(...values) : 0
|
|
112
|
+
const maxValue = values.length > 0 ? Math.max(...values) : 100
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!chartRef.current) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 获取地图数据:优先使用用户提供的 mapJson,否则使用内置地图
|
|
120
|
+
const geoJson = mapJson || BUILTIN_MAP_JSON[mapType]
|
|
121
|
+
|
|
122
|
+
// 注册地图(避免重复注册)
|
|
123
|
+
const mapKey = mapJson ? `custom_${mapType}` : mapType
|
|
124
|
+
if (!registeredMaps.has(mapKey) && geoJson) {
|
|
125
|
+
echarts.registerMap(mapType, geoJson as Parameters<typeof echarts.registerMap>[1])
|
|
126
|
+
registeredMaps.add(mapKey)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
chartInstance.current = echarts.init(chartRef.current)
|
|
130
|
+
|
|
131
|
+
const option = {
|
|
132
|
+
backgroundColor: 'transparent',
|
|
133
|
+
tooltip: showTooltip
|
|
134
|
+
? {
|
|
135
|
+
trigger: 'item',
|
|
136
|
+
backgroundColor: 'rgba(0, 15, 35, 0.95)',
|
|
137
|
+
borderColor: 'rgba(0, 242, 254, 0.6)',
|
|
138
|
+
borderWidth: 1,
|
|
139
|
+
padding: [10, 15],
|
|
140
|
+
textStyle: {
|
|
141
|
+
color: '#fff',
|
|
142
|
+
fontSize: 13,
|
|
143
|
+
},
|
|
144
|
+
formatter: (params: { name: string; value?: number; seriesType: string }) => {
|
|
145
|
+
if (params.seriesType === 'effectScatter') {
|
|
146
|
+
return `<div style="font-weight:500">${params.name}</div>`
|
|
147
|
+
}
|
|
148
|
+
return `<div style="font-weight:500">${params.name}</div><div style="color:#00f2fe;margin-top:4px">${params.value?.toLocaleString() ?? '-'}</div>`
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
: { show: false },
|
|
152
|
+
visualMap: showVisualMap
|
|
153
|
+
? {
|
|
154
|
+
min: minValue,
|
|
155
|
+
max: maxValue,
|
|
156
|
+
left: 20,
|
|
157
|
+
bottom: 20,
|
|
158
|
+
itemWidth: 12,
|
|
159
|
+
itemHeight: 100,
|
|
160
|
+
text: ['高', '低'],
|
|
161
|
+
textStyle: {
|
|
162
|
+
color: 'rgba(255, 255, 255, 0.7)',
|
|
163
|
+
fontSize: 11,
|
|
164
|
+
},
|
|
165
|
+
inRange: {
|
|
166
|
+
color: ['#0a2e4e', '#0d4a6e', '#1a6a8e', '#2a8aae', '#4abadd', '#00f2fe'],
|
|
167
|
+
},
|
|
168
|
+
calculable: true,
|
|
169
|
+
}
|
|
170
|
+
: undefined,
|
|
171
|
+
geo: {
|
|
172
|
+
map: mapType,
|
|
173
|
+
roam,
|
|
174
|
+
zoom: 1.2,
|
|
175
|
+
label: {
|
|
176
|
+
show: false,
|
|
177
|
+
},
|
|
178
|
+
emphasis: {
|
|
179
|
+
label: {
|
|
180
|
+
show: true,
|
|
181
|
+
color: '#fff',
|
|
182
|
+
fontSize: 12,
|
|
183
|
+
fontWeight: 500,
|
|
184
|
+
},
|
|
185
|
+
itemStyle: {
|
|
186
|
+
areaColor: {
|
|
187
|
+
type: 'linear',
|
|
188
|
+
x: 0,
|
|
189
|
+
y: 0,
|
|
190
|
+
x2: 0,
|
|
191
|
+
y2: 1,
|
|
192
|
+
colorStops: [
|
|
193
|
+
{ offset: 0, color: '#00f2fe' },
|
|
194
|
+
{ offset: 1, color: '#4facfe' },
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
shadowColor: glowEffect ? 'rgba(0, 242, 254, 0.8)' : 'transparent',
|
|
198
|
+
shadowBlur: glowEffect ? 25 : 0,
|
|
199
|
+
borderColor: '#00f2fe',
|
|
200
|
+
borderWidth: 2,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
itemStyle: {
|
|
204
|
+
areaColor: {
|
|
205
|
+
type: 'linear',
|
|
206
|
+
x: 0,
|
|
207
|
+
y: 0,
|
|
208
|
+
x2: 0,
|
|
209
|
+
y2: 1,
|
|
210
|
+
colorStops: [
|
|
211
|
+
{ offset: 0, color: '#0d2b4a' },
|
|
212
|
+
{ offset: 1, color: '#051428' },
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
borderColor: 'rgba(0, 242, 254, 0.3)',
|
|
216
|
+
borderWidth: 1,
|
|
217
|
+
shadowColor: glowEffect ? 'rgba(0, 242, 254, 0.15)' : 'transparent',
|
|
218
|
+
shadowBlur: glowEffect ? 8 : 0,
|
|
219
|
+
shadowOffsetY: glowEffect ? 2 : 0,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
series: [
|
|
223
|
+
{
|
|
224
|
+
name: '区域数据',
|
|
225
|
+
type: 'map',
|
|
226
|
+
map: mapType,
|
|
227
|
+
geoIndex: 0,
|
|
228
|
+
data: regionData,
|
|
229
|
+
},
|
|
230
|
+
...(showScatter
|
|
231
|
+
? [
|
|
232
|
+
{
|
|
233
|
+
name: '散点',
|
|
234
|
+
type: 'effectScatter' as const,
|
|
235
|
+
coordinateSystem: 'geo' as const,
|
|
236
|
+
data: scatterData.map(item => ({
|
|
237
|
+
name: item.name,
|
|
238
|
+
value: item.value,
|
|
239
|
+
})),
|
|
240
|
+
symbolSize: (val: number[]) => {
|
|
241
|
+
const size = (val[2] / maxValue) * scatterSymbolSize + scatterSymbolSize / 2
|
|
242
|
+
return Math.max(size, 8)
|
|
243
|
+
},
|
|
244
|
+
showEffectOn: 'render' as const,
|
|
245
|
+
rippleEffect: {
|
|
246
|
+
brushType: 'stroke' as const,
|
|
247
|
+
scale: 4,
|
|
248
|
+
period: 4,
|
|
249
|
+
},
|
|
250
|
+
itemStyle: {
|
|
251
|
+
color: {
|
|
252
|
+
type: 'radial',
|
|
253
|
+
x: 0.5,
|
|
254
|
+
y: 0.5,
|
|
255
|
+
r: 0.5,
|
|
256
|
+
colorStops: [
|
|
257
|
+
{ offset: 0, color: '#fff' },
|
|
258
|
+
{ offset: 0.3, color: chartColors[0] },
|
|
259
|
+
{ offset: 1, color: chartColors[0] },
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
shadowColor: glowEffect ? chartColors[0] : 'transparent',
|
|
263
|
+
shadowBlur: glowEffect ? 15 : 0,
|
|
264
|
+
},
|
|
265
|
+
zlevel: 1,
|
|
266
|
+
},
|
|
267
|
+
]
|
|
268
|
+
: []),
|
|
269
|
+
],
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
chartInstance.current.setOption(option)
|
|
273
|
+
|
|
274
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
275
|
+
chartInstance.current?.resize()
|
|
276
|
+
})
|
|
277
|
+
resizeObserver.observe(chartRef.current)
|
|
278
|
+
|
|
279
|
+
return () => {
|
|
280
|
+
resizeObserver.disconnect()
|
|
281
|
+
chartInstance.current?.dispose()
|
|
282
|
+
}
|
|
283
|
+
}, [
|
|
284
|
+
mapType,
|
|
285
|
+
mapJson,
|
|
286
|
+
regionData,
|
|
287
|
+
scatterData,
|
|
288
|
+
chartColors,
|
|
289
|
+
showVisualMap,
|
|
290
|
+
showTooltip,
|
|
291
|
+
showScatter,
|
|
292
|
+
scatterSymbolSize,
|
|
293
|
+
glowEffect,
|
|
294
|
+
roam,
|
|
295
|
+
minValue,
|
|
296
|
+
maxValue,
|
|
297
|
+
])
|
|
298
|
+
|
|
299
|
+
const containerStyle: CSSProperties = {
|
|
300
|
+
width: '100%',
|
|
301
|
+
height: '100%',
|
|
302
|
+
transform: rotation !== 0 ? `rotate(${rotation}deg)` : undefined,
|
|
303
|
+
opacity: opacity / 100,
|
|
304
|
+
backgroundColor: background,
|
|
305
|
+
...externalStyle,
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<div
|
|
310
|
+
className={styles.container}
|
|
311
|
+
onClick={onClick}
|
|
312
|
+
onDoubleClick={onDoubleClick}
|
|
313
|
+
onMouseEnter={onMouseEnter}
|
|
314
|
+
onMouseLeave={onMouseLeave}
|
|
315
|
+
ref={ref}
|
|
316
|
+
style={containerStyle}
|
|
317
|
+
>
|
|
318
|
+
<div className={styles.chart} ref={chartRef} />
|
|
319
|
+
</div>
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export default GeoMap
|