From e962fa039ac9f2814676d677d30750f581d13c64 Mon Sep 17 00:00:00 2001
From: 无木 <netfan@foxmail.com>
Date: Sat, 29 Oct 2022 10:05:44 +0800
Subject: [PATCH] fix: auto resize echart on menu collapsed, fixed #2265

---
 src/hooks/web/useECharts.ts | 8 ++++++++
 1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/hooks/web/useECharts.ts b/src/hooks/web/useECharts.ts
index cdc02ef..6324e4a 100644
--- a/src/hooks/web/useECharts.ts
+++ b/src/hooks/web/useECharts.ts
@@ -8,12 +8,14 @@ import { useEventListener } from '/@/hooks/event/useEventListener';
 import { useBreakpoint } from '/@/hooks/event/useBreakpoint';
 import echarts from '/@/utils/lib/echarts';
 import { useRootSetting } from '/@/hooks/setting/useRootSetting';
+import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
 
 export function useECharts(
   elRef: Ref<HTMLDivElement>,
   theme: 'light' | 'dark' | 'default' = 'default',
 ) {
   const { getDarkMode: getSysDarkMode } = useRootSetting();
+  const { getCollapsed } = useMenuSetting();
 
   const getDarkMode = computed(() => {
     return theme === 'default' ? getSysDarkMode.value : theme;
@@ -98,6 +100,12 @@ export function useECharts(
     },
   );
 
+  watch(getCollapsed, (_) => {
+    useTimeoutFn(() => {
+      resizeFn();
+    }, 300);
+  });
+
   tryOnUnmounted(() => {
     if (!chartInstance) return;
     removeResizeFn();
--
libgit2 0.23.3