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

Method layoutInner

src/component/legend/LegendView.ts:518–587  ·  view source on GitHub ↗
(
        legendModel: LegendModel,
        itemAlign: LegendOption['align'],
        maxSize: { width: number, height: number },
        isFirstRender: boolean,
        selector: LegendOption['selector'],
        selectorPosition: LegendOption['selectorPosition']
    )

Source from the content-addressed store, hash-verified

516 }
517
518 protected layoutInner(
519 legendModel: LegendModel,
520 itemAlign: LegendOption['align'],
521 maxSize: { width: number, height: number },
522 isFirstRender: boolean,
523 selector: LegendOption['selector'],
524 selectorPosition: LegendOption['selectorPosition']
525 ): ZRRectLike {
526 const contentGroup = this.getContentGroup();
527 const selectorGroup = this.getSelectorGroup();
528
529 // Place items in contentGroup.
530 layoutUtil.box(
531 legendModel.get('orient'),
532 contentGroup,
533 legendModel.get('itemGap'),
534 maxSize.width,
535 maxSize.height
536 );
537
538 const contentRect = contentGroup.getBoundingRect();
539 const contentPos = [-contentRect.x, -contentRect.y];
540
541 selectorGroup.markRedraw();
542 contentGroup.markRedraw();
543
544 if (selector) {
545 // Place buttons in selectorGroup
546 layoutUtil.box(
547 // Buttons in selectorGroup always layout horizontally
548 'horizontal',
549 selectorGroup,
550 legendModel.get('selectorItemGap', true)
551 );
552
553 const selectorRect = selectorGroup.getBoundingRect();
554 const selectorPos = [-selectorRect.x, -selectorRect.y];
555 const selectorButtonGap = legendModel.get('selectorButtonGap', true);
556
557 const orientIdx = legendModel.getOrient().index;
558 const wh: 'width' | 'height' = orientIdx === 0 ? 'width' : 'height';
559 const hw: 'width' | 'height' = orientIdx === 0 ? 'height' : 'width';
560 const yx: 'x' | 'y' = orientIdx === 0 ? 'y' : 'x';
561
562 if (selectorPosition === 'end') {
563 selectorPos[orientIdx] += contentRect[wh] + selectorButtonGap;
564 }
565 else {
566 contentPos[orientIdx] += selectorRect[wh] + selectorButtonGap;
567 }
568
569 // Always align selector to content as 'middle'
570 selectorPos[1 - orientIdx] += contentRect[hw] / 2 - selectorRect[hw] / 2;
571 selectorGroup.x = selectorPos[0];
572 selectorGroup.y = selectorPos[1];
573 contentGroup.x = contentPos[0];
574 contentGroup.y = contentPos[1];
575

Callers 1

renderMethod · 0.95

Calls 5

getContentGroupMethod · 0.95
getSelectorGroupMethod · 0.95
getMethod · 0.45
getBoundingRectMethod · 0.45
getOrientMethod · 0.45

Tested by

no test coverage detected