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

Function brushPreprocessor

src/component/brush/preprocessor.ts:30–69  ·  view source on GitHub ↗
(option: ECUnitOption, isNew: boolean)

Source from the content-addressed store, hash-verified

28const DEFAULT_TOOLBOX_BTNS: BrushToolboxIconType[] = ['rect', 'polygon', 'keep', 'clear'];
29
30export default function brushPreprocessor(option: ECUnitOption, isNew: boolean): void {
31 const brushComponents = normalizeToArray(option ? option.brush : []);
32
33 if (!brushComponents.length) {
34 return;
35 }
36
37 let brushComponentSpecifiedBtns = [] as string[];
38
39 zrUtil.each(brushComponents, function (brushOpt: BrushOption) {
40 const tbs = brushOpt.hasOwnProperty('toolbox')
41 ? brushOpt.toolbox : [];
42
43 if (tbs instanceof Array) {
44 brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
45 }
46 });
47
48 let toolbox: ToolboxOption = option && option.toolbox;
49
50 if (zrUtil.isArray(toolbox)) {
51 toolbox = toolbox[0];
52 }
53 if (!toolbox) {
54 toolbox = {feature: {}};
55 option.toolbox = [toolbox];
56 }
57
58 const toolboxFeature = (toolbox.feature || (toolbox.feature = {}));
59 const toolboxBrush = (toolboxFeature.brush || (toolboxFeature.brush = {})) as ToolboxBrushFeatureOption;
60 const brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
61
62 brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
63
64 removeDuplicates(brushTypes, item => item + '', null);
65
66 if (isNew && !brushTypes.length) {
67 brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
68 }
69}

Callers

nothing calls this directly

Calls 3

normalizeToArrayFunction · 0.90
removeDuplicatesFunction · 0.90
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…