From c6ccb414f74c3602a540d6035014b63f3aac37fb Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 18 Nov 2022 17:02:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9C=B0=E5=9B=BE):=20=E5=A4=9A=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E6=95=B0=E6=8D=AE=E4=B8=8B=E9=92=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/chart/map/map.js | 4 ++-- .../src/views/chart/components/ChartComponent.vue | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) 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) {