zzz-pc-view 0.0.167 → 0.0.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.es.js +16 -5
- package/src/index.umd.js +1 -1
package/package.json
CHANGED
package/src/index.es.js
CHANGED
|
@@ -4213,8 +4213,9 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
4213
4213
|
const props = __props;
|
|
4214
4214
|
const emit = __emit;
|
|
4215
4215
|
const elRef = shallowRef();
|
|
4216
|
-
|
|
4216
|
+
const chartInstanceRef = shallowRef();
|
|
4217
4217
|
const setChartOption = () => {
|
|
4218
|
+
const chartInstance = chartInstanceRef.value;
|
|
4218
4219
|
chartInstance.resize();
|
|
4219
4220
|
const { chartOption } = props.renderParam;
|
|
4220
4221
|
if (chartOption) {
|
|
@@ -4222,21 +4223,23 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
4222
4223
|
}
|
|
4223
4224
|
};
|
|
4224
4225
|
const init = () => {
|
|
4225
|
-
chartInstance = ECharts.init(elRef.value, props.theme);
|
|
4226
|
+
const chartInstance = chartInstanceRef.value = ECharts.init(elRef.value, props.theme);
|
|
4226
4227
|
emit("ready", chartInstance);
|
|
4227
4228
|
setChartOption();
|
|
4228
4229
|
};
|
|
4229
4230
|
const destroy = () => {
|
|
4231
|
+
const chartInstance = chartInstanceRef.value;
|
|
4230
4232
|
if (!chartInstance) {
|
|
4231
4233
|
return;
|
|
4232
4234
|
}
|
|
4233
4235
|
emit("destroy", chartInstance);
|
|
4234
4236
|
chartInstance.clear();
|
|
4235
4237
|
chartInstance.dispose();
|
|
4236
|
-
|
|
4238
|
+
chartInstanceRef.value = void 0;
|
|
4237
4239
|
};
|
|
4238
4240
|
const resize = () => {
|
|
4239
|
-
|
|
4241
|
+
var _a2;
|
|
4242
|
+
(_a2 = chartInstanceRef.value) == null ? void 0 : _a2.resize();
|
|
4240
4243
|
};
|
|
4241
4244
|
let windowResizeTimer;
|
|
4242
4245
|
const clearWindowResizeTimer = () => {
|
|
@@ -4244,6 +4247,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
4244
4247
|
};
|
|
4245
4248
|
const onWindowResize = () => {
|
|
4246
4249
|
clearWindowResizeTimer();
|
|
4250
|
+
const chartInstance = chartInstanceRef.value;
|
|
4247
4251
|
if (chartInstance) {
|
|
4248
4252
|
windowResizeTimer = window.setTimeout(() => {
|
|
4249
4253
|
resize();
|
|
@@ -4253,13 +4257,20 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
4253
4257
|
watch(
|
|
4254
4258
|
() => props.theme,
|
|
4255
4259
|
() => {
|
|
4260
|
+
const chartInstance = chartInstanceRef.value;
|
|
4261
|
+
if (!chartInstance) {
|
|
4262
|
+
return;
|
|
4263
|
+
}
|
|
4264
|
+
const chartOption = chartInstance.getOption();
|
|
4256
4265
|
destroy();
|
|
4257
4266
|
init();
|
|
4267
|
+
chartInstanceRef.value.setOption(chartOption, true);
|
|
4258
4268
|
}
|
|
4259
4269
|
);
|
|
4260
4270
|
watch(
|
|
4261
4271
|
() => props.renderParam.chartOption,
|
|
4262
4272
|
() => {
|
|
4273
|
+
const chartInstance = chartInstanceRef.value;
|
|
4263
4274
|
if (!chartInstance) {
|
|
4264
4275
|
return;
|
|
4265
4276
|
}
|
|
@@ -4294,7 +4305,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
4294
4305
|
* @returns {EChartsType | undefined} 当前 ECharts 图表实例,如果未初始化则返回 undefined。
|
|
4295
4306
|
*/
|
|
4296
4307
|
get chartInstance() {
|
|
4297
|
-
return
|
|
4308
|
+
return chartInstanceRef.value;
|
|
4298
4309
|
},
|
|
4299
4310
|
// 暴露 resize 方法,供父组件调用,用于调整 ECharts 图表实例的大小
|
|
4300
4311
|
resize
|