fix: echarts地图高级配置地名映射会影响地图颜色#6192

This commit is contained in:
fit2cloud-chenyw 2023-11-09 17:39:09 +08:00
parent 65a6fd2c48
commit 6157b74c8b

View File

@ -467,6 +467,25 @@ export default {
}
}
const chart_option = baseMapOption(base_json, geoJson, chart, this.buttonTextColor, curAreaCode, this.currentSeriesId)
if (chart_option.series?.length) {
const dataNames = []
chart_option.series.filter(se => se.type === 'map').forEach(se => {
se.data.forEach(d => {
if (d?.name) {
dataNames.push(d.name)
}
})
})
for (const key in chart_option.geo.nameMap) {
if (Object.hasOwnProperty.call(chart_option.geo.nameMap, key)) {
const element = chart_option.geo.nameMap[key]
if (element && !dataNames.includes(element)) {
chart_option.geo.nameMap[key] = key
}
}
}
}
this.myEcharts(chart_option)
const opt = this.myChart.getOption()
if (opt && opt.series) {