fix: remove unnecessary install, ensure initial resize

This commit is contained in:
Justineo
2021-03-08 19:20:28 +08:00
parent 5f22f4a0c2
commit 6ca29ed3e0

View File

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { import {
install,
defineComponent, defineComponent,
ref, ref,
unref, unref,
@ -39,8 +38,6 @@ import {
import "./style.css"; import "./style.css";
import { omitOn } from "./utils"; import { omitOn } from "./utils";
install();
const TAG_NAME = "x-vue-echarts"; const TAG_NAME = "x-vue-echarts";
if (Vue2) { if (Vue2) {
@ -145,10 +142,14 @@ export default defineComponent({
instance.setOption(option || realOption.value, realUpdateOptions.value); 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) // Make sure the chart fits the container in next UI render (after current task)
setTimeout(() => { nextTick(resize);
instance.resize(); setTimeout(resize);
});
} }
function setOption(option: Option, updateOptions?: UpdateOptions) { function setOption(option: Option, updateOptions?: UpdateOptions) {