From 6ca29ed3e09208b95c969764ebf0e5d07571e962 Mon Sep 17 00:00:00 2001 From: Justineo Date: Mon, 8 Mar 2021 19:20:28 +0800 Subject: [PATCH] fix: remove unnecessary install, ensure initial resize --- src/ECharts.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ECharts.ts b/src/ECharts.ts index fd98607..ab25c76 100644 --- a/src/ECharts.ts +++ b/src/ECharts.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { - install, defineComponent, ref, unref, @@ -39,8 +38,6 @@ import { import "./style.css"; import { omitOn } from "./utils"; -install(); - const TAG_NAME = "x-vue-echarts"; if (Vue2) { @@ -145,10 +142,14 @@ export default defineComponent({ instance.setOption(option || realOption.value, realUpdateOptions.value); + function resize() { + if (instance && !instance.isDisposed()) { + instance.resize(); + } + } // Make sure the chart fits the container in next UI render (after current task) - setTimeout(() => { - instance.resize(); - }); + nextTick(resize); + setTimeout(resize); } function setOption(option: Option, updateOptions?: UpdateOptions) {