MCPcopy Index your code
hub / github.com/apache/echarts / setOption

Method setOption

src/model/OptionManager.ts:87–151  ·  view source on GitHub ↗
(
        rawOption: ECBasicOption,
        optionPreprocessorFuncs: OptionPreprocessor[],
        opt: InnerSetOptionOpts
    )

Source from the content-addressed store, hash-verified

85 }
86
87 setOption(
88 rawOption: ECBasicOption,
89 optionPreprocessorFuncs: OptionPreprocessor[],
90 opt: InnerSetOptionOpts
91 ): void {
92 if (rawOption) {
93 // That set dat primitive is dangerous if user reuse the data when setOption again.
94 each(normalizeToArray((rawOption as ECUnitOption).series), function (series: SeriesOption) {
95 series && series.data && isTypedArray(series.data) && setAsPrimitive(series.data);
96 });
97 each(normalizeToArray((rawOption as ECUnitOption).dataset), function (dataset: DatasetOption) {
98 dataset && dataset.source && isTypedArray(dataset.source) && setAsPrimitive(dataset.source);
99 });
100 }
101
102 // Caution: some series modify option data, if do not clone,
103 // it should ensure that the repeat modify correctly
104 // (create a new object when modify itself).
105 rawOption = clone(rawOption);
106
107 // FIXME
108 // If some property is set in timeline options or media option but
109 // not set in baseOption, a warning should be given.
110
111 const optionBackup = this._optionBackup;
112 const newParsedOption = parseRawOption(
113 rawOption, optionPreprocessorFuncs, !optionBackup
114 );
115 this._newBaseOption = newParsedOption.baseOption;
116
117 // For setOption at second time (using merge mode);
118 if (optionBackup) {
119 // FIXME
120 // the restore merge solution is essentially incorrect.
121 // the mapping can not be 100% consistent with ecModel, which probably brings
122 // potential bug!
123
124 // The first merge is delayed, because in most cases, users do not call `setOption` twice.
125 // let fakeCmptsMap = this._fakeCmptsMap;
126 // if (!fakeCmptsMap) {
127 // fakeCmptsMap = this._fakeCmptsMap = createHashMap();
128 // mergeToBackupOption(fakeCmptsMap, null, optionBackup.baseOption, null);
129 // }
130
131 // mergeToBackupOption(
132 // fakeCmptsMap, optionBackup.baseOption, newParsedOption.baseOption, opt
133 // );
134
135 // For simplicity, timeline options and media options do not support merge,
136 // that is, if you `setOption` twice and both has timeline options, the latter
137 // timeline options will not be merged to the former, but just substitute them.
138 if (newParsedOption.timelineOptions.length) {
139 optionBackup.timelineOptions = newParsedOption.timelineOptions;
140 }
141 if (newParsedOption.mediaList.length) {
142 optionBackup.mediaList = newParsedOption.mediaList;
143 }
144 if (newParsedOption.mediaDefault) {

Callers

nothing calls this directly

Calls 4

normalizeToArrayFunction · 0.90
cloneFunction · 0.85
parseRawOptionFunction · 0.85
eachFunction · 0.50

Tested by

no test coverage detected