From c89d1d1fe4e820bc9d1a942467a3f1e017b40dac Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 06 十一月 2024 16:33:36 +0800
Subject: [PATCH] 无关代码删除

---
 src/components/chat/chatComponents/hooks/useDrawChatChart.ts |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/components/chat/chatComponents/hooks/useDrawChatChart.ts b/src/components/chat/chatComponents/hooks/useDrawChatChart.ts
index c90a711..2f057e5 100644
--- a/src/components/chat/chatComponents/hooks/useDrawChatChart.ts
+++ b/src/components/chat/chatComponents/hooks/useDrawChatChart.ts
@@ -16,25 +16,30 @@
 		resizeChart?.(width, height);
 	};
 
-	const initChart = ()=>{
+	const initChart = () => {
 		setTimeout(() => {
-			const parent = chartRef.value.parentElement;
-			const parentBound = parent.getBoundingClientRect();
-			chartInstance.value = echarts.init(chartRef.value, undefined, {
-				width: parentBound.width,
-				height: parentBound.height,
-				locale: 'ZH',
-			});
-			resizeChart = debounce((width, height) => {
-				chartInstance.value.resize({
-					width: width,
-					height: height,
+			const instance = echarts.getInstanceByDom(chartRef.value);
+			if (!instance) {
+				const parent = chartRef.value.parentElement;
+				const parentBound = parent.getBoundingClientRect();
+
+				chartInstance.value = echarts.init(chartRef.value, undefined, {
+					width: parentBound.width,
+					height: parentBound.height,
+					locale: 'ZH',
 				});
-			});
+
+				resizeChart = debounce((width, height) => {
+					chartInstance.value.resize({
+						width: width,
+						height: height,
+					});
+				});
+			}
 
 			drawChart();
 		}, 100);
-	}
+	};
 
 	onMounted(() => {
 		initChart();
@@ -43,5 +48,6 @@
 	return {
 		chartContainerResize,
 		chartInstance,
+		
 	};
 };

--
Gitblit v1.9.3