Skip to content

Commit ebd26ff

Browse files
committed
Merge branch 'fix-theme-switch-keep-data' of https://github.com/mustcanbedo/echarts into fix-theme-switch-keep-data
2 parents 2565079 + 6c4ba79 commit ebd26ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/core/echarts.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ class ECharts extends Eventful<ECEventDefinition> {
744744
return;
745745
}
746746

747+
const backup = typeof this.getOption === 'function' ? this.getOption() : null;
748+
747749
let silent = opts && opts.silent;
748750
let updateParams = null as UpdateLifecycleParams;
749751

@@ -761,9 +763,6 @@ class ECharts extends Eventful<ECEventDefinition> {
761763
try {
762764
this._updateTheme(theme);
763765
ecModel.setTheme(this._theme);
764-
765-
prepare(this);
766-
updateMethods.update.call(this, {type: 'setTheme'}, updateParams);
767766
}
768767
catch (e) {
769768
this[IN_MAIN_PROCESS_KEY] = false;
@@ -772,6 +771,13 @@ class ECharts extends Eventful<ECEventDefinition> {
772771

773772
this[IN_MAIN_PROCESS_KEY] = false;
774773

774+
if (backup) {
775+
this.setOption(backup as any, { notMerge: true, lazyUpdate: false, silent: !!silent });
776+
return;
777+
}
778+
779+
prepare(this);
780+
updateMethods.update.call(this, {type: 'setTheme'}, updateParams);
775781
flushPendingActions.call(this, silent);
776782
triggerUpdatedEvent.call(this, silent);
777783
}

0 commit comments

Comments
 (0)