perf(地图): 优化地图后台逻辑

This commit is contained in:
fit2cloud-chenyw
2022-12-19 16:43:48 +08:00
parent ac6f412586
commit 4dd805cf05
3 changed files with 38 additions and 9 deletions

View File

@@ -48,9 +48,9 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seri
let currentSeriesId = seriesId
const yAxis = JSON.parse(chart.yaxis)
if (!currentSeriesId || !yAxis.some(item => item.id === currentSeriesId)) {
currentSeriesId = yAxis[0].id
currentSeriesId = yAxis?.length ? yAxis[0].id : null
}
chart.data.series.forEach((item, index) => {
chart.data?.series.forEach((item, index) => {
if (item.data[0].quotaList[0].id === currentSeriesId) {
seriesIndex = index
return false
@@ -213,7 +213,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seri
}
const val = values[valueIndex]
const field = deNameArray[valueIndex]
const con = getSvgCondition(val, field, markCondition.conditions)
const con = getSvgCondition(val, field, markCondition?.conditions || null)
let svgName = null
if (con) {
svgName = con.icon
@@ -227,7 +227,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seri
color: params => {
const { value } = params
const val = value[valueIndex]
const con = getSvgCondition(val, null, markCondition.conditions)
const con = getSvgCondition(val, null, markCondition?.conditions || null)
return con?.color || '#b02a02'
}
},
@@ -248,6 +248,9 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seri
}
const getSvgCondition = (val, field, conditions) => {
if (!conditions) {
return null
}
for (let i = 0; i < conditions.length; i++) {
const condition = conditions[i]
if (conditionMatch(condition, val)) {

View File

@@ -455,20 +455,20 @@ export default {
},
roamMap(flag) {
let targetZoom = 1
const zoom = this.myChart.getOption().series[0].zoom
const zoom = this.myChart.getOption().geo[0].zoom
if (flag) {
targetZoom = zoom * 1.2
} else {
targetZoom = zoom / 1.2
}
const options = JSON.parse(JSON.stringify(this.myChart.getOption()))
options.series[0].zoom = targetZoom
options.geo[0].zoom = targetZoom
this.myChart.setOption(options)
},
resetZoom() {
const options = JSON.parse(JSON.stringify(this.myChart.getOption()))
options.series[0].zoom = 1
options.series[0].center = this.mapCenter
options.geo[0].zoom = 1
options.geo[0].center = this.mapCenter
this.myChart.setOption(options)
}
}