From d7d7466524e8f07c4590862b2a539795553a01fe Mon Sep 17 00:00:00 2001 From: zhou <31909825+zhouOB@users.noreply.github.com> Date: Sun, 27 Oct 2024 21:18:36 +0800 Subject: [PATCH] fix: fix renderEcharts refresh issue (#4741) --- packages/effects/plugins/src/echarts/use-echarts.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/effects/plugins/src/echarts/use-echarts.ts b/packages/effects/plugins/src/echarts/use-echarts.ts index d4282cd4..bbe31590 100644 --- a/packages/effects/plugins/src/echarts/use-echarts.ts +++ b/packages/effects/plugins/src/echarts/use-echarts.ts @@ -31,12 +31,11 @@ function useEcharts(chartRef: Ref) { const getOptions = computed((): EChartsOption => { if (!isDark.value) { - return cacheOptions; + return {}; } return { backgroundColor: 'transparent', - ...cacheOptions, }; }); @@ -52,10 +51,14 @@ function useEcharts(chartRef: Ref) { const renderEcharts = (options: EChartsOption, clear = true) => { cacheOptions = options; + const currentOptions = { + ...options, + ...getOptions.value, + }; return new Promise((resolve) => { if (chartRef.value?.offsetHeight === 0) { useTimeoutFn(() => { - renderEcharts(getOptions.value); + renderEcharts(currentOptions); resolve(null); }, 30); return; @@ -67,7 +70,7 @@ function useEcharts(chartRef: Ref) { if (!instance) return; } clear && chartInstance?.clear(); - chartInstance?.setOption(getOptions.value); + chartInstance?.setOption(currentOptions); resolve(null); }, 30); });