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

Function setLabelStyle

src/label/labelStyle.ts:212–305  ·  view source on GitHub ↗
(
    targetEl: Element,
    labelStatesModels: LabelStatesModels<LabelModel>,
    opt?: SetLabelStyleOpt<TLabelDataIndex>,
    stateSpecified?: Partial<Record<DisplayState, TextStyleProps>>
    // TODO specified position?
)

Source from the content-addressed store, hash-verified

210 stateSpecified?: Partial<Record<DisplayState, TextStyleProps>>
211): void;
212function setLabelStyle<TLabelDataIndex>(
213 targetEl: Element,
214 labelStatesModels: LabelStatesModels<LabelModel>,
215 opt?: SetLabelStyleOpt<TLabelDataIndex>,
216 stateSpecified?: Partial<Record<DisplayState, TextStyleProps>>
217 // TODO specified position?
218) {
219 opt = opt || EMPTY_OBJ;
220 const isSetOnText = targetEl instanceof ZRText;
221 let needsCreateText = false;
222 for (let i = 0; i < DISPLAY_STATES.length; i++) {
223 const stateModel = labelStatesModels[DISPLAY_STATES[i]];
224 if (stateModel && stateModel.getShallow('show')) {
225 needsCreateText = true;
226 break;
227 }
228 }
229 let textContent = isSetOnText ? targetEl as ZRText : targetEl.getTextContent();
230 if (needsCreateText) {
231 if (!isSetOnText) {
232 // Reuse the previous
233 if (!textContent) {
234 textContent = new ZRText();
235 targetEl.setTextContent(textContent);
236 }
237 // Use same state proxy
238 if (targetEl.stateProxy) {
239 textContent.stateProxy = targetEl.stateProxy;
240 }
241 }
242 const labelStatesTexts = getLabelText(opt, labelStatesModels);
243
244 const normalModel = labelStatesModels.normal;
245 const showNormal = !!normalModel.getShallow('show');
246 const normalStyle = createTextStyle(
247 normalModel, stateSpecified && stateSpecified.normal, opt, false, !isSetOnText
248 );
249 normalStyle.text = labelStatesTexts.normal;
250 if (!isSetOnText) {
251 // Always create new
252 targetEl.setTextConfig(createTextConfig(normalModel, opt, false));
253 }
254
255 for (let i = 0; i < SPECIAL_STATES.length; i++) {
256 const stateName = SPECIAL_STATES[i];
257 const stateModel = labelStatesModels[stateName];
258
259 if (stateModel) {
260 const stateObj = textContent.ensureState(stateName);
261 const stateShow = !!retrieve2(stateModel.getShallow('show'), showNormal);
262 if (stateShow !== showNormal) {
263 stateObj.ignore = !stateShow;
264 }
265 stateObj.style = createTextStyle(
266 stateModel, stateSpecified && stateSpecified[stateName], opt, true, !isSetOnText
267 );
268 stateObj.style.text = labelStatesTexts[stateName];
269

Callers 15

_updateLabelMethod · 0.90
_renderOnGridLikeMethod · 0.90
renderMethod · 0.90
_renderSymbolsMethod · 0.90
_updateCommonStlMethod · 0.90
_updateCommonMethod · 0.90
updateStyleFunction · 0.90
updateCommonFunction · 0.90
_updateLabelMethod · 0.90
_updateLabelMethod · 0.90
processMethod · 0.90
_initOrUpdateEndLabelMethod · 0.90

Calls 6

getLabelTextFunction · 0.85
createTextConfigFunction · 0.85
setLabelTextFunction · 0.85
getShallowMethod · 0.80
createTextStyleFunction · 0.70
dirtyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…