From 15b1f28fb9ba90d2a2137a9a4cddef0b5a4128cc Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:00:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E6=8A=98=E7=BA=BF=E5=9B=BE=E9=80=89=E6=8B=A9=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#4656)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #4647 --- frontend/src/components/v-charts/components/Line.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/v-charts/components/Line.vue b/frontend/src/components/v-charts/components/Line.vue index d8e85fbe1..0658b3f7c 100644 --- a/frontend/src/components/v-charts/components/Line.vue +++ b/frontend/src/components/v-charts/components/Line.vue @@ -83,7 +83,8 @@ const seriesStyle = [ function initChart() { let itemChart = echarts?.getInstanceByDom(document.getElementById(props.id) as HTMLElement); - // 如果不存在,就进行初始化 + const optionItem = itemChart?.getOption(); + const itemSelect = optionItem?.legend; if (itemChart == null) { itemChart = echarts.init(document.getElementById(props.id) as HTMLElement); } @@ -109,10 +110,9 @@ function initChart() { yAxis.push({ splitLine: { show: true, - //分隔辅助线 lineStyle: { - type: 'dashed', //线的类型 虚线0 - opacity: theme === 'dark' ? 0.1 : 1, //透明度 + type: 'dashed', + opacity: theme === 'dark' ? 0.1 : 1, }, }, ...item, @@ -120,7 +120,6 @@ function initChart() { }); } - // 把配置和数据放这里 const option = { title: [ { @@ -168,7 +167,7 @@ function initChart() { }, }, grid: props.option.grid || { left: '7%', right: '7%', bottom: '20%' }, - legend: { + legend: itemSelect || { right: 10, itemWidth: 8, textStyle: {