refactor(图表): 自定义区域支持地名映射
This commit is contained in:
parent
63242dfa53
commit
862854fb00
@ -3,6 +3,7 @@ import { computed, nextTick, onMounted, PropType, reactive, ref, watch } from 'v
|
||||
import { getGeoJsonFile, parseJson } from '../../../js/util'
|
||||
import { forEach, debounce } from 'lodash-es'
|
||||
import { toRefs } from 'vue'
|
||||
import { getCustomGeoArea } from '@/api/map'
|
||||
|
||||
const props = defineProps({
|
||||
chart: {
|
||||
@ -70,7 +71,11 @@ const getAreaMapping = async areaId => {
|
||||
return {}
|
||||
}
|
||||
if (areaId.startsWith('custom_')) {
|
||||
areaId = '156'
|
||||
const areaList = (await getCustomGeoArea(areaId)).data
|
||||
return areaList.reduce((p, n) => {
|
||||
p[n.name] = n.name
|
||||
return p
|
||||
}, {})
|
||||
}
|
||||
const geoJson = await getGeoJsonFile(areaId)
|
||||
return geoJson.features.reduce((p, n) => {
|
||||
|
||||
@ -99,7 +99,12 @@ export class Map extends L7PlotChartView<ChoroplethOptions, Choropleth> {
|
||||
p['156' + n.properties.adcode] = n.properties.name
|
||||
return p
|
||||
}, {})
|
||||
const { areaMapping } = parseJson(chart.senior)
|
||||
const areaMap = customSubArea.reduce((p, n) => {
|
||||
const mappedName = areaMapping?.[areaId]?.[n.name]
|
||||
if (mappedName) {
|
||||
n.name = mappedName
|
||||
}
|
||||
p[n.name] = n
|
||||
n.scopeArr = n.scope?.split(',') || []
|
||||
return p
|
||||
|
||||
Loading…
Reference in New Issue
Block a user