zzz-pc-view 0.0.167 → 0.0.169

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zzz-pc-view",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "main": "src/index.umd.js",
5
5
  "module": "src/index.es.js",
6
6
  "types": "src/index.d.ts",
package/src/index.es.js CHANGED
@@ -4213,30 +4213,44 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4213
4213
  const props = __props;
4214
4214
  const emit = __emit;
4215
4215
  const elRef = shallowRef();
4216
- let chartInstance;
4216
+ const chartInstanceRef = shallowRef();
4217
4217
  const setChartOption = () => {
4218
+ const chartInstance = chartInstanceRef.value;
4218
4219
  chartInstance.resize();
4219
- const { chartOption } = props.renderParam;
4220
- if (chartOption) {
4220
+ const { chartOption: chartOption2 } = props.renderParam;
4221
+ if (chartOption2) {
4221
4222
  chartInstance.setOption(props.renderParam.chartOption, true);
4222
4223
  }
4223
4224
  };
4225
+ let chartOption;
4224
4226
  const init = () => {
4225
- chartInstance = ECharts.init(elRef.value, props.theme);
4227
+ const chartInstance = chartInstanceRef.value = ECharts.init(elRef.value, props.theme);
4228
+ const setOption = chartInstance.setOption;
4229
+ const clear2 = chartInstance.clear;
4230
+ chartInstance.setOption = function(...args) {
4231
+ setOption.call(chartInstance, ...args);
4232
+ chartOption = args[0];
4233
+ };
4234
+ chartInstance.clear = function() {
4235
+ chartOption = void 0;
4236
+ clear2.call(chartInstance);
4237
+ };
4226
4238
  emit("ready", chartInstance);
4227
4239
  setChartOption();
4228
4240
  };
4229
4241
  const destroy = () => {
4242
+ const chartInstance = chartInstanceRef.value;
4230
4243
  if (!chartInstance) {
4231
4244
  return;
4232
4245
  }
4233
4246
  emit("destroy", chartInstance);
4234
4247
  chartInstance.clear();
4235
4248
  chartInstance.dispose();
4236
- chartInstance = void 0;
4249
+ chartInstanceRef.value = void 0;
4237
4250
  };
4238
4251
  const resize = () => {
4239
- chartInstance == null ? void 0 : chartInstance.resize();
4252
+ var _a2;
4253
+ (_a2 = chartInstanceRef.value) == null ? void 0 : _a2.resize();
4240
4254
  };
4241
4255
  let windowResizeTimer;
4242
4256
  const clearWindowResizeTimer = () => {
@@ -4244,6 +4258,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4244
4258
  };
4245
4259
  const onWindowResize = () => {
4246
4260
  clearWindowResizeTimer();
4261
+ const chartInstance = chartInstanceRef.value;
4247
4262
  if (chartInstance) {
4248
4263
  windowResizeTimer = window.setTimeout(() => {
4249
4264
  resize();
@@ -4253,13 +4268,21 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4253
4268
  watch(
4254
4269
  () => props.theme,
4255
4270
  () => {
4271
+ const chartInstance = chartInstanceRef.value;
4272
+ if (!chartInstance) {
4273
+ return;
4274
+ }
4256
4275
  destroy();
4257
4276
  init();
4277
+ if (chartOption) {
4278
+ chartInstanceRef.value.setOption(chartOption, true);
4279
+ }
4258
4280
  }
4259
4281
  );
4260
4282
  watch(
4261
4283
  () => props.renderParam.chartOption,
4262
4284
  () => {
4285
+ const chartInstance = chartInstanceRef.value;
4263
4286
  if (!chartInstance) {
4264
4287
  return;
4265
4288
  }
@@ -4294,7 +4317,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4294
4317
  * @returns {EChartsType | undefined} 当前 ECharts 图表实例,如果未初始化则返回 undefined。
4295
4318
  */
4296
4319
  get chartInstance() {
4297
- return chartInstance;
4320
+ return chartInstanceRef.value;
4298
4321
  },
4299
4322
  // 暴露 resize 方法,供父组件调用,用于调整 ECharts 图表实例的大小
4300
4323
  resize