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

Function createTextConfig

src/label/labelStyle.ts:340–383  ·  view source on GitHub ↗
(
    textStyleModel: Model<LabelOption<{positionExtra: 'outside'}>>,
    opt?: Pick<
        TextCommonParams,
        'defaultOutsidePosition' | 'inheritColor' | 'autoOverflowArea' | 'layoutRect'
    >,
    isNotNormal?: boolean
)

Source from the content-addressed store, hash-verified

338 return textStyle;
339}
340export function createTextConfig(
341 textStyleModel: Model<LabelOption<{positionExtra: 'outside'}>>,
342 opt?: Pick<
343 TextCommonParams,
344 'defaultOutsidePosition' | 'inheritColor' | 'autoOverflowArea' | 'layoutRect'
345 >,
346 isNotNormal?: boolean
347) {
348 opt = opt || {};
349 const textConfig: ElementTextConfig = {};
350 let labelPosition;
351 let labelRotate = textStyleModel.getShallow('rotate');
352 const labelDistance = retrieve2(textStyleModel.getShallow('distance'), isNotNormal ? null : 5);
353 const labelOffset = textStyleModel.getShallow('offset');
354 labelPosition = textStyleModel.getShallow('position')
355 || (isNotNormal ? null : 'inside');
356 // 'outside' is not a valid zr textPostion value, but used
357 // in bar series, and magic type should be considered.
358 labelPosition === 'outside' && (labelPosition = opt.defaultOutsidePosition || 'top');
359 if (labelPosition != null) {
360 textConfig.position = labelPosition;
361 }
362 if (labelOffset != null) {
363 textConfig.offset = labelOffset;
364 }
365 if (labelRotate != null) {
366 labelRotate *= Math.PI / 180;
367 textConfig.rotation = labelRotate;
368 }
369 if (labelDistance != null) {
370 textConfig.distance = labelDistance;
371 }
372 // fill and auto is determined by the color of path fill if it's not specified by developers.
373 textConfig.outsideFill = textStyleModel.get('color') === 'inherit'
374 ? (opt.inheritColor || null)
375 : 'auto';
376 if (opt.autoOverflowArea != null) {
377 textConfig.autoOverflowArea = opt.autoOverflowArea;
378 }
379 if (opt.layoutRect != null) {
380 textConfig.layoutRect = opt.layoutRect;
381 }
382 return textConfig;
383}
384
385/**
386 * The uniform entry of set text style, that is, retrieve style definitions

Callers 1

setLabelStyleFunction · 0.85

Calls 2

getShallowMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…