diff --git a/frontend/src/views/chart/chart/map/map.js b/frontend/src/views/chart/chart/map/map.js index 2675295976..fbc331b0cb 100644 --- a/frontend/src/views/chart/chart/map/map.js +++ b/frontend/src/views/chart/chart/map/map.js @@ -37,7 +37,7 @@ const fillGradientColor = (data, colors) => { }) return data } -export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) { +export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seriesId) { // 处理shape attr let customAttr = {} let isGradient = false @@ -45,7 +45,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) { if (chart.customAttr) { customAttr = JSON.parse(chart.customAttr) if (chart.yaxis && chart.yaxis.length > 1) { - let currentSeriesId = customAttr.currentSeriesId + let currentSeriesId = seriesId const yAxis = JSON.parse(chart.yaxis) if (!currentSeriesId || !yAxis.some(item => item.id === currentSeriesId)) { currentSeriesId = yAxis[0].id diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 89862e73df..1c8cedf253 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -119,7 +119,8 @@ export default { linkageActiveParam: null, buttonTextColor: null, loading: true, - showSuspension: true + showSuspension: true, + currentSeriesId: null } }, @@ -132,6 +133,11 @@ export default { ]) }, watch: { + currentSeriesId(value, old) { + if (value !== old) { + this.preDraw() + } + }, chart: { handler(newVal, oldVla) { this.preDraw() @@ -171,9 +177,7 @@ export default { if (id !== this.chart.id) { return } - const customAttr = JSON.parse(this.chart.customAttr) - customAttr.currentSeriesId = seriesId - this.chart.customAttr = JSON.stringify(customAttr) + this.currentSeriesId = seriesId }, reDrawView() { this.myChart.dispatchAction({ @@ -366,7 +370,7 @@ export default { 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) const opt = this.myChart.getOption() if (opt && opt.series) {