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

Method render

src/component/title/install.ts:148–286  ·  view source on GitHub ↗
(titleModel: TitleModel, ecModel: GlobalModel, api: ExtensionAPI)

Source from the content-addressed store, hash-verified

146
147
148 render(titleModel: TitleModel, ecModel: GlobalModel, api: ExtensionAPI) {
149 this.group.removeAll();
150
151 if (!titleModel.get('show')) {
152 return;
153 }
154
155 const group = this.group;
156
157 const textStyleModel = titleModel.getModel('textStyle');
158 const subtextStyleModel = titleModel.getModel('subtextStyle');
159
160 let textAlign = titleModel.get('textAlign');
161 let textVerticalAlign = zrUtil.retrieve2(
162 titleModel.get('textBaseline'), titleModel.get('textVerticalAlign')
163 );
164
165 const textEl = new graphic.Text({
166 style: createTextStyle(textStyleModel, {
167 text: titleModel.get('text'),
168 fill: textStyleModel.getTextColor()
169 }, {disableBox: true}),
170 z2: 10
171 });
172
173 const textRect = textEl.getBoundingRect();
174
175 const subText = titleModel.get('subtext');
176 const subTextEl = new graphic.Text({
177 style: createTextStyle(subtextStyleModel, {
178 text: subText,
179 fill: subtextStyleModel.getTextColor(),
180 y: textRect.height + titleModel.get('itemGap'),
181 verticalAlign: 'top'
182 }, {disableBox: true}),
183 z2: 10
184 });
185
186 const link = titleModel.get('link');
187 const sublink = titleModel.get('sublink');
188 const triggerEvent = titleModel.get('triggerEvent', true);
189
190 textEl.silent = !link && !triggerEvent;
191 subTextEl.silent = !sublink && !triggerEvent;
192
193 if (link) {
194 textEl.on('click', function () {
195 windowOpen(link, '_' + titleModel.get('target'));
196 });
197 }
198 if (sublink) {
199 subTextEl.on('click', function () {
200 windowOpen(sublink, '_' + titleModel.get('subtarget'));
201 });
202 }
203
204 getECData(textEl).eventData = getECData(subTextEl).eventData = triggerEvent
205 ? {

Callers

nothing calls this directly

Calls 12

createTextStyleFunction · 0.90
windowOpenFunction · 0.90
createBoxLayoutReferenceFunction · 0.90
getLayoutRectFunction · 0.90
getTextColorMethod · 0.80
getBoxLayoutParamsMethod · 0.80
setStyleMethod · 0.80
getItemStyleMethod · 0.80
getMethod · 0.45
getModelMethod · 0.45
getBoundingRectMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected