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

Function createBoxLayoutReference

src/util/layout.ts:476–525  ·  view source on GitHub ↗
(
    model: ComponentModel,
    api: ExtensionAPI,
    opt?: CreateBoxLayoutReferenceOpt<TEnableByCenter>
)

Source from the content-addressed store, hash-verified

474 * - Use `dataToLayout` to get the `refContainer`, such as, in matrix coord sys.
475 */
476export function createBoxLayoutReference<TEnableByCenter extends boolean = false>(
477 model: ComponentModel,
478 api: ExtensionAPI,
479 opt?: CreateBoxLayoutReferenceOpt<TEnableByCenter>
480): BoxLayoutReferenceResult<TEnableByCenter> {
481
482 let refContainer: RectLike | NullUndefined;
483 let refPoint: number[] | NullUndefined;
484 let layoutRefType: BoxLayoutReferenceType | NullUndefined;
485
486 const boxCoordSys = model.boxCoordinateSystem;
487 let boxCoordFrom: BoxCoordinateSystemCoordFrom | NullUndefined;
488 if (boxCoordSys) {
489 const {coord, from} = getCoordForCoordSysUsageKindBox(model);
490 // Do not use `clamp` in `dataToLayout` and `dataToPoint`, because:
491 // 1. Should support overflow (such as, by dataZoom), where NaN should be in the result.
492 // 2. Be consistent with the way used in `series.data`
493 if (boxCoordSys.dataToLayout) {
494 layoutRefType = BoxLayoutReferenceType.rect;
495 boxCoordFrom = from;
496 const result = boxCoordSys.dataToLayout(coord);
497 refContainer = result.contentRect || result.rect;
498 }
499 else if (opt && opt.enableLayoutOnlyByCenter && boxCoordSys.dataToPoint) {
500 layoutRefType = BoxLayoutReferenceType.point;
501 boxCoordFrom = from;
502 refPoint = boxCoordSys.dataToPoint(coord);
503 }
504 else {
505 if (__DEV__) {
506 error(`${model.type}[${model.componentIndex}]`
507 + ` layout based on ${boxCoordSys.type} is not supported.`
508 );
509 }
510 }
511 }
512
513 if (layoutRefType == null) {
514 layoutRefType = BoxLayoutReferenceType.rect;
515 }
516
517 if (layoutRefType === BoxLayoutReferenceType.rect) {
518 if (!refContainer) {
519 refContainer = {x: 0, y: 0, width: api.getWidth(), height: api.getHeight()};
520 }
521 refPoint = [refContainer.x + refContainer.width / 2, refContainer.y + refContainer.height / 2];
522 }
523
524 return {type: layoutRefType, refContainer, refPoint, boxCoordFrom} as BoxLayoutReferenceResult<TEnableByCenter>;
525}
526
527
528/**

Callers 11

sankeyLayoutFunction · 0.90
getViewRectFunction · 0.90
commonLayoutFunction · 0.90
renderMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
resizeMethod · 0.90
resizeMethod · 0.90
resizeMethod · 0.90
resizePolarFunction · 0.90

Calls 6

errorFunction · 0.90
dataToLayoutMethod · 0.65
dataToPointMethod · 0.65
getWidthMethod · 0.65
getHeightMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…