MCPcopy
hub / github.com/apache/echarts / setOption

Method setOption

src/core/echarts.ts:740–819  ·  view source on GitHub ↗
(option: Opt, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean)

Source from the content-addressed store, hash-verified

738 setOption<Opt extends ECBasicOption>(option: Opt, opts?: SetOptionOpts): void;
739 /* eslint-disable-next-line */
740 setOption<Opt extends ECBasicOption>(option: Opt, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean): void {
741 if (this[IN_EC_CYCLE_KEY]) {
742 if (__DEV__) {
743 error('`setOption` should not be called during main process.');
744 }
745 return;
746 }
747
748 if (this._disposed) {
749 disposedWarning(this.id);
750 return;
751 }
752
753 let silent;
754 let replaceMerge;
755 let transitionOpt: SetOptionTransitionOpt;
756 if (isObject(notMerge)) {
757 lazyUpdate = notMerge.lazyUpdate;
758 silent = notMerge.silent;
759 replaceMerge = notMerge.replaceMerge;
760 transitionOpt = notMerge.transition;
761 notMerge = notMerge.notMerge;
762 }
763
764 this[IN_EC_CYCLE_KEY] = true;
765 updateECUpdateCycleVersion(this);
766
767 if (!this._model || notMerge) {
768 const optionManager = new OptionManager(this._api);
769 const theme = this._theme;
770 const ecModel = this._model = new GlobalModel();
771 ecModel.scheduler = this._scheduler;
772 ecModel.ssr = this._ssr;
773 ecModel.init(null, null, null, theme, this._locale, optionManager);
774 }
775
776 this._model.setOption(option as ECBasicOption, { replaceMerge }, optionPreprocessorFuncs);
777
778 const updateParams = {
779 seriesTransition: transitionOpt,
780 optionChanged: true
781 } as UpdateLifecycleParams;
782
783 if (lazyUpdate) {
784 this[PENDING_UPDATE] = {
785 silent: silent,
786 updateParams: updateParams
787 };
788 this[IN_EC_CYCLE_KEY] = false;
789
790 // `setOption(option, {lazyMode: true})` may be called when zrender has been slept.
791 // It should wake it up to make sure zrender start to render at the next frame.
792 this.getZr().wakeUp();
793 }
794 else {
795 try {
796 prepare(this);
797 updateMethods.update.call(this, null, updateParams);

Callers 15

clearMethod · 0.95
renderHomepage3DemoFunction · 0.45
importPartial.tsFile · 0.45
basic.tsFile · 0.45
event.tsFile · 0.45
initFunction · 0.45
initFunction · 0.45
testHelper.jsFile · 0.45
interval.test.tsFile · 0.45
setOption.test.tsFile · 0.45
setOption.test.tsFile · 0.45

Calls 5

getZrMethod · 0.95
errorFunction · 0.90
disposedWarningFunction · 0.85
isObjectFunction · 0.50
initMethod · 0.45

Tested by

no test coverage detected