Merge pull request #13605 from dataease/pr@dev-v2@refactor_custom_area_name_mapping

refactor(图表): 自定义区域支持地名映射
This commit is contained in:
wisonic-s 2024-11-27 15:42:20 +08:00 committed by GitHub
commit 6cd6548695
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { computed, nextTick, onMounted, PropType, reactive, ref, watch } from 'v
import { getGeoJsonFile, parseJson } from '../../../js/util' import { getGeoJsonFile, parseJson } from '../../../js/util'
import { forEach, debounce } from 'lodash-es' import { forEach, debounce } from 'lodash-es'
import { toRefs } from 'vue' import { toRefs } from 'vue'
import { getCustomGeoArea } from '@/api/map'
const props = defineProps({ const props = defineProps({
chart: { chart: {
@ -70,7 +71,11 @@ const getAreaMapping = async areaId => {
return {} return {}
} }
if (areaId.startsWith('custom_')) { 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) const geoJson = await getGeoJsonFile(areaId)
return geoJson.features.reduce((p, n) => { return geoJson.features.reduce((p, n) => {

View File

@ -99,7 +99,12 @@ export class Map extends L7PlotChartView<ChoroplethOptions, Choropleth> {
p['156' + n.properties.adcode] = n.properties.name p['156' + n.properties.adcode] = n.properties.name
return p return p
}, {}) }, {})
const { areaMapping } = parseJson(chart.senior)
const areaMap = customSubArea.reduce((p, n) => { const areaMap = customSubArea.reduce((p, n) => {
const mappedName = areaMapping?.[areaId]?.[n.name]
if (mappedName) {
n.name = mappedName
}
p[n.name] = n p[n.name] = n
n.scopeArr = n.scope?.split(',') || [] n.scopeArr = n.scope?.split(',') || []
return p return p