From a47a4849ebe547628822719a21ff201e04968b64 Mon Sep 17 00:00:00 2001 From: ahanhanhan Date: Wed, 13 Mar 2024 12:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/LineChart.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/dashboard/LineChart.vue b/src/views/dashboard/LineChart.vue index aa5484b..7c88a29 100644 --- a/src/views/dashboard/LineChart.vue +++ b/src/views/dashboard/LineChart.vue @@ -102,6 +102,7 @@ export default { mounted() { publisherInstance.subscribe('refresh', this.staticAmountLine); this.$nextTick(() => { + this.chart = echarts.init(this.$refs.chart, 'macarons') this.staticAmountLine(); }) }, @@ -112,20 +113,25 @@ export default { if (code === 200) { const { x } = data; echartsConfig.xAxis.data = x; + const series = []; for (const key in legendMap) { const name = legendMap[key]; - echartsConfig.series.push({ + series.push({ name, yAxisIndex: key === 'orderCountData' ? 1 : 0, data: data[key], type: "line", }) } + const options = this.chart.getOption(); + if (options && options.legend) { + echartsConfig.legend = { selected: options.legend[0].selected } + } + echartsConfig.series = series; this.initChart(echartsConfig) } }, initChart(chartData) { - this.chart = echarts.init(this.$refs.chart, 'macarons') this.chart.setOption(chartData); }, },