From 3f86f91ae46b730375ec8823fe72588e92928ab9 Mon Sep 17 00:00:00 2001 From: 100pah Date: Thu, 13 May 2021 14:02:59 +0800 Subject: [PATCH 1/2] fix: resize throw error. fix #14846, fix #11395 . --- src/core/echarts.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core/echarts.ts b/src/core/echarts.ts index f9da887f05..68f764b24e 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -1160,13 +1160,23 @@ class ECharts extends Eventful { return; } - const optionChanged = ecModel.resetOption('media'); + let needPrepare = ecModel.resetOption('media'); - const silent = opts && opts.silent; + let silent = opts && opts.silent; + + // There is some real cases that: + // chart.setOption(option, { lazyUpdate: true }); + // chart.resize(); + if (this[OPTION_UPDATED_KEY]) { + silent = silent || (this[OPTION_UPDATED_KEY] as any).silent; + needPrepare = true; + this[OPTION_UPDATED_KEY] = false; + } this[IN_MAIN_PROCESS_KEY] = true; - optionChanged && prepare(this); + needPrepare && prepare(this); + updateMethods.update.call(this, { type: 'resize', animation: zrUtil.extend({ From a06096a1f2446d8ea2a4c223f9c7b26a2057ddd8 Mon Sep 17 00:00:00 2001 From: 100pah Date: Thu, 13 May 2021 14:23:49 +0800 Subject: [PATCH 2/2] fix: if resize silent specified with not null/undefined, always use resize silent. --- src/core/echarts.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/echarts.ts b/src/core/echarts.ts index 68f764b24e..f2ba620956 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -1168,7 +1168,9 @@ class ECharts extends Eventful { // chart.setOption(option, { lazyUpdate: true }); // chart.resize(); if (this[OPTION_UPDATED_KEY]) { - silent = silent || (this[OPTION_UPDATED_KEY] as any).silent; + if (silent == null) { + silent = (this[OPTION_UPDATED_KEY] as any).silent; + } needPrepare = true; this[OPTION_UPDATED_KEY] = false; }