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

Method render

src/component/legend/LegendView.ts:104–166  ·  view source on GitHub ↗

* @override

(
        legendModel: LegendModel,
        ecModel: GlobalModel,
        api: ExtensionAPI
    )

Source from the content-addressed store, hash-verified

102 * @override
103 */
104 render(
105 legendModel: LegendModel,
106 ecModel: GlobalModel,
107 api: ExtensionAPI
108 ) {
109 const isFirstRender = this._isFirstRender;
110 this._isFirstRender = false;
111
112 this.resetInner();
113
114 if (!legendModel.get('show', true)) {
115 return;
116 }
117
118 let itemAlign = legendModel.get('align');
119 const orient = legendModel.get('orient');
120 if (!itemAlign || itemAlign === 'auto') {
121 itemAlign = (
122 legendModel.get('left') === 'right'
123 && orient === 'vertical'
124 ) ? 'right' : 'left';
125 }
126
127 // selector has been normalized to an array in model
128 const selector = legendModel.get('selector', true) as LegendSelectorButtonOption[];
129 let selectorPosition = legendModel.get('selectorPosition', true);
130 if (selector && (!selectorPosition || selectorPosition === 'auto')) {
131 selectorPosition = orient === 'horizontal' ? 'end' : 'start';
132 }
133
134 this.renderInner(itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition);
135
136 // Perform layout.
137 const refContainer = layoutUtil.createBoxLayoutReference(legendModel, api).refContainer;
138 const positionInfo = legendModel.getBoxLayoutParams();
139 const padding = legendModel.get('padding');
140
141 const maxSize = layoutUtil.getLayoutRect(positionInfo, refContainer, padding);
142
143 const mainRect = this.layoutInner(legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition);
144
145 // Place mainGroup, based on the calculated `mainRect`.
146 const layoutRect = layoutUtil.getLayoutRect(
147 zrUtil.defaults({
148 width: mainRect.width,
149 height: mainRect.height
150 }, positionInfo),
151 refContainer,
152 padding
153 );
154 this.group.x = layoutRect.x - mainRect.x;
155 this.group.y = layoutRect.y - mainRect.y;
156 this.group.markRedraw();
157
158 // Render background after group is layout.
159 this.group.add(
160 this._backgroundEl = makeBackground(
161 mainRect,

Callers

nothing calls this directly

Calls 7

resetInnerMethod · 0.95
renderInnerMethod · 0.95
layoutInnerMethod · 0.95
makeBackgroundFunction · 0.90
getBoxLayoutParamsMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected