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

Method _resetSelected

src/component/visualMap/PiecewiseModel.ts:212–242  ·  view source on GitHub ↗
(newOption: PiecewiseVisualMapOption, isInit?: boolean)

Source from the content-addressed store, hash-verified

210 }
211
212 private _resetSelected(newOption: PiecewiseVisualMapOption, isInit?: boolean) {
213 const thisOption = this.option;
214 const pieceList = this._pieceList;
215
216 // Selected do not merge but all override.
217 const selected = (isInit ? thisOption : newOption).selected || {};
218 thisOption.selected = selected;
219
220 // Consider 'not specified' means true.
221 zrUtil.each(pieceList, function (piece, index) {
222 const key = this.getSelectedMapKey(piece);
223 if (!selected.hasOwnProperty(key)) {
224 selected[key] = true;
225 }
226 }, this);
227
228 if (thisOption.selectedMode === 'single') {
229 // Ensure there is only one selected.
230 let hasSel = false;
231
232 zrUtil.each(pieceList, function (piece, index) {
233 const key = this.getSelectedMapKey(piece);
234 if (selected[key]) {
235 hasSel
236 ? (selected[key] = false)
237 : (hasSel = true);
238 }
239 }, this);
240 }
241 // thisOption.selectedMode === 'multiple', default: all selected.
242 }
243
244 /**
245 * @public

Callers 1

optionUpdatedMethod · 0.95

Calls 2

getSelectedMapKeyMethod · 0.95
eachMethod · 0.45

Tested by

no test coverage detected