Merge pull request #3798 from dataease/pr@dev@fix_map_switch_series_drill

fix(地图): 多系列数据下钻问题
This commit is contained in:
Junjun 2022-11-18 17:18:39 +08:00 committed by GitHub
commit 944b0d06dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -37,7 +37,7 @@ const fillGradientColor = (data, colors) => {
}) })
return data return data
} }
export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) { export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seriesId) {
// 处理shape attr // 处理shape attr
let customAttr = {} let customAttr = {}
let isGradient = false let isGradient = false
@ -45,7 +45,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
if (chart.customAttr) { if (chart.customAttr) {
customAttr = JSON.parse(chart.customAttr) customAttr = JSON.parse(chart.customAttr)
if (chart.yaxis && chart.yaxis.length > 1) { if (chart.yaxis && chart.yaxis.length > 1) {
let currentSeriesId = customAttr.currentSeriesId let currentSeriesId = seriesId
const yAxis = JSON.parse(chart.yaxis) const yAxis = JSON.parse(chart.yaxis)
if (!currentSeriesId || !yAxis.some(item => item.id === currentSeriesId)) { if (!currentSeriesId || !yAxis.some(item => item.id === currentSeriesId)) {
currentSeriesId = yAxis[0].id currentSeriesId = yAxis[0].id

View File

@ -119,7 +119,8 @@ export default {
linkageActiveParam: null, linkageActiveParam: null,
buttonTextColor: null, buttonTextColor: null,
loading: true, loading: true,
showSuspension: true showSuspension: true,
currentSeriesId: null
} }
}, },
@ -132,6 +133,11 @@ export default {
]) ])
}, },
watch: { watch: {
currentSeriesId(value, old) {
if (value !== old) {
this.preDraw()
}
},
chart: { chart: {
handler(newVal, oldVla) { handler(newVal, oldVla) {
this.preDraw() this.preDraw()
@ -171,9 +177,7 @@ export default {
if (id !== this.chart.id) { if (id !== this.chart.id) {
return return
} }
const customAttr = JSON.parse(this.chart.customAttr) this.currentSeriesId = seriesId
customAttr.currentSeriesId = seriesId
this.chart.customAttr = JSON.stringify(customAttr)
}, },
reDrawView() { reDrawView() {
this.myChart.dispatchAction({ this.myChart.dispatchAction({
@ -366,7 +370,7 @@ export default {
this.buttonTextColor = null this.buttonTextColor = null
} }
} }
const chart_option = baseMapOption(base_json, chart, this.buttonTextColor, curAreaCode) const chart_option = baseMapOption(base_json, chart, this.buttonTextColor, curAreaCode, this.currentSeriesId)
this.myEcharts(chart_option) this.myEcharts(chart_option)
const opt = this.myChart.getOption() const opt = this.myChart.getOption()
if (opt && opt.series) { if (opt && opt.series) {