...
|
...
|
@@ -28,6 +28,7 @@ import { isPreview } from '@/utils' |
28
|
28
|
import mapJsonWithoutHainanIsLands from './mapWithoutHainanIsLands.json'
|
29
|
29
|
import { DatasetComponent, GridComponent, TooltipComponent, GeoComponent, VisualMapComponent } from 'echarts/components'
|
30
|
30
|
import { getGeoJsonMap } from '@/api/external/common'
|
|
31
|
+import dataJson from './data.json'
|
31
|
32
|
|
32
|
33
|
const props = defineProps({
|
33
|
34
|
themeSetting: {
|
...
|
...
|
@@ -106,15 +107,21 @@ props.chartConfig.option = { |
106
|
107
|
//地图点击返回 adcode=100000,名字必须是china
|
107
|
108
|
const watchAdcode = async () => {
|
108
|
109
|
if (props.chartConfig.option.drillingIn) {
|
|
110
|
+ let saveAdcode: any = saveLevelStr.parentInfo.adcode
|
109
|
111
|
saveLevelStr.level = saveLevelStr.parentInfo.level
|
110
|
|
- await getGeojson(saveLevelStr.parentInfo.adcode)
|
111
|
|
- props.chartConfig.option.geo.map =
|
112
|
|
- saveLevelStr.parentInfo.adcode === 100000 ? 'china' : saveLevelStr.parentInfo.adcode
|
|
112
|
+ if (saveAdcode === 0) {
|
|
113
|
+ //
|
|
114
|
+ saveAdcode = 'china'
|
|
115
|
+ saveLevelStr.level = 'COUNTRY'
|
|
116
|
+ }
|
|
117
|
+ await getGeojson(saveAdcode)
|
|
118
|
+ const adcode = saveAdcode === 100000 ? 'china' : saveAdcode
|
|
119
|
+ props.chartConfig.option.geo.map = adcode
|
113
|
120
|
props.chartConfig.option.series.forEach((item: any) => {
|
114
|
|
- if (item.type === 'map')
|
115
|
|
- item.map = saveLevelStr.parentInfo.adcode === 100000 ? 'china' : saveLevelStr.parentInfo.adcode
|
|
121
|
+ if (item.type === 'map') item.map = adcode
|
116
|
122
|
})
|
117
|
123
|
vEchartsSetOption()
|
|
124
|
+ handleDataPoint(adcode)
|
118
|
125
|
}
|
119
|
126
|
}
|
120
|
127
|
|
...
|
...
|
@@ -145,7 +152,8 @@ const getGeojson = async (regionId: any) => { |
145
|
152
|
const geoJsonFile = JSON.parse(geoJson)
|
146
|
153
|
if (!geoJsonFile) return
|
147
|
154
|
saveGeojson.value = geoJsonFile
|
148
|
|
- registerMap(level === areaEnum.COUNTRY ? name : code, { geoJSON: geoJsonFile as any, specialAreas: {} })
|
|
155
|
+ const nameChina = name === '中国' ? 'china' : name
|
|
156
|
+ registerMap(level === areaEnum.COUNTRY ? nameChina : code, { geoJSON: geoJsonFile as any, specialAreas: {} })
|
149
|
157
|
loading.value = false
|
150
|
158
|
} catch (error) {
|
151
|
159
|
loading.value = false
|
...
|
...
|
@@ -200,17 +208,17 @@ const hainanLandsHandle = async (newData: boolean) => { |
200
|
208
|
}
|
201
|
209
|
}
|
202
|
210
|
|
203
|
|
-//监听 dataset 数据发生变化
|
204
|
|
-// watch(
|
205
|
|
-// () => props.chartConfig.option.dataset,
|
206
|
|
-// newData => {
|
207
|
|
-// dataSetHandle(newData)
|
208
|
|
-// },
|
209
|
|
-// {
|
210
|
|
-// immediate: true,
|
211
|
|
-// deep: false
|
212
|
|
-// }
|
213
|
|
-// )
|
|
211
|
+// 监听 dataset 数据发生变化
|
|
212
|
+watch(
|
|
213
|
+ () => props.chartConfig.option.dataset,
|
|
214
|
+ newData => {
|
|
215
|
+ dataSetHandle(newData)
|
|
216
|
+ },
|
|
217
|
+ {
|
|
218
|
+ immediate: true,
|
|
219
|
+ deep: false
|
|
220
|
+ }
|
|
221
|
+)
|
214
|
222
|
|
215
|
223
|
//监听是否显示南海群岛
|
216
|
224
|
watch(
|
...
|
...
|
@@ -228,6 +236,18 @@ watch( |
228
|
236
|
}
|
229
|
237
|
)
|
230
|
238
|
|
|
239
|
+//处理数据标点
|
|
240
|
+const handleDataPoint = (newData: any) => {
|
|
241
|
+ if (newData === 'china') {
|
|
242
|
+ dataSetHandle(dataJson)
|
|
243
|
+ } else {
|
|
244
|
+ const filterPoint = dataJson.point.filter((item: any) => item.adcode === newData)
|
|
245
|
+ dataSetHandle({
|
|
246
|
+ point: filterPoint
|
|
247
|
+ })
|
|
248
|
+ }
|
|
249
|
+}
|
|
250
|
+
|
231
|
251
|
//监听地图展示区域发生变化
|
232
|
252
|
watch(
|
233
|
253
|
() => props.chartConfig.option.mapRegion.adcode,
|
...
|
...
|
@@ -239,6 +259,7 @@ watch( |
239
|
259
|
if (item.type === 'map') item.map = newData
|
240
|
260
|
})
|
241
|
261
|
vEchartsSetOption()
|
|
262
|
+ handleDataPoint(newData)
|
242
|
263
|
} catch (error) {
|
243
|
264
|
console.log(error)
|
244
|
265
|
}
|
...
|
...
|
@@ -272,6 +293,7 @@ const handleVChartClick = async (params: any) => { |
272
|
293
|
saveLevelStr.level = level
|
273
|
294
|
saveLevelStr.parentInfo.adcode = item.properties.parent.adcode //保存上一级的地区编码
|
274
|
295
|
saveLevelStr.parentInfo.level = (regionMapParentArea as any)[level] //保存上一级的行政级别
|
|
296
|
+ handleDataPoint(adcode)
|
275
|
297
|
}
|
276
|
298
|
})
|
277
|
299
|
}
|
...
|
...
|
|