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

Method render

src/component/toolbox/ToolboxView.ts:66–372  ·  view source on GitHub ↗
(
        toolboxModel: ToolboxModel,
        ecModel: GlobalModel,
        api: ExtensionAPI,
        payload: Payload & {
            newTitle?: ToolboxFeatureOption['title']
        }
    )

Source from the content-addressed store, hash-verified

64 _featureNames: FeatureName[];
65
66 render(
67 toolboxModel: ToolboxModel,
68 ecModel: GlobalModel,
69 api: ExtensionAPI,
70 payload: Payload & {
71 newTitle?: ToolboxFeatureOption['title']
72 }
73 ) {
74 const group = this.group;
75 group.removeAll();
76
77 if (!toolboxModel.get('show')) {
78 return;
79 }
80
81 const itemSize = +toolboxModel.get('itemSize');
82 const isVertical = toolboxModel.get('orient') === 'vertical';
83 const featureOpts = toolboxModel.get('feature') || {};
84 const features = this._features || (this._features = createHashMap());
85
86 const newFeatureNames: FeatureName[] = []; // Includes both `show: true/false`.
87 each(featureOpts, function (opt, name) {
88 newFeatureNames.push(name);
89 });
90
91 // Diff by feature name.
92 (new DataDiffer(this._featureNames || [], newFeatureNames))
93 .add(processFeature)
94 .update(processFeature)
95 .remove(curry(processFeature, null))
96 .execute();
97
98 // Keep for diff.
99 this._featureNames = filter(newFeatureNames, function (name) {
100 return features.hasKey(name);
101 });
102
103 function processFeature(newIndex: number | NullUndefined, oldIndex?: number | NullUndefined) {
104 const isDiffAdd = newIndex != null && oldIndex == null;
105 const isDiffUpdate = newIndex != null && oldIndex != null;
106 const isDiffRemove = newIndex == null;
107
108 const featureName = (isDiffAdd || isDiffUpdate)
109 ? newFeatureNames[newIndex]
110 : newFeatureNames[oldIndex];
111 const featureOpt = featureOpts[featureName];
112 const featureModel = (isDiffAdd || isDiffUpdate)
113 ? new Model(featureOpt, toolboxModel, ecModel) as ToolboxFeatureModel
114 : null;
115 // `.get('show')` Also considered UserDefinedToolboxFeature
116 const isFeatureShow = featureModel && featureModel.get('show');
117
118 let feature: ToolboxFeature | UserDefinedToolboxFeature;
119
120 if (isDiffAdd) { // DIFF_ADD
121 if (!isFeatureShow) {
122 return;
123 }

Callers

nothing calls this directly

Calls 14

createBoxLayoutReferenceFunction · 0.90
getLayoutRectFunction · 0.90
positionElementFunction · 0.90
executeMethod · 0.80
getBoxLayoutParamsMethod · 0.80
removeMethod · 0.65
updateMethod · 0.65
getHeightMethod · 0.65
getWidthMethod · 0.65
eachFunction · 0.50
isFunctionFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected