MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / boxLayout

Function boxLayout

libs/echarts/echarts-en.simple.js:19588–19650  ·  view source on GitHub ↗
(orient, group, gap, maxWidth, maxHeight)

Source from the content-addressed store, hash-verified

19586];
19587
19588function boxLayout(orient, group, gap, maxWidth, maxHeight) {
19589 var x = 0;
19590 var y = 0;
19591
19592 if (maxWidth == null) {
19593 maxWidth = Infinity;
19594 }
19595 if (maxHeight == null) {
19596 maxHeight = Infinity;
19597 }
19598 var currentLineMaxSize = 0;
19599
19600 group.eachChild(function (child, idx) {
19601 var position = child.position;
19602 var rect = child.getBoundingRect();
19603 var nextChild = group.childAt(idx + 1);
19604 var nextChildRect = nextChild && nextChild.getBoundingRect();
19605 var nextX;
19606 var nextY;
19607
19608 if (orient === 'horizontal') {
19609 var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
19610 nextX = x + moveX;
19611 // Wrap when width exceeds maxWidth or meet a `newline` group
19612 // FIXME compare before adding gap?
19613 if (nextX > maxWidth || child.newline) {
19614 x = 0;
19615 nextX = moveX;
19616 y += currentLineMaxSize + gap;
19617 currentLineMaxSize = rect.height;
19618 }
19619 else {
19620 // FIXME: consider rect.y is not `0`?
19621 currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
19622 }
19623 }
19624 else {
19625 var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
19626 nextY = y + moveY;
19627 // Wrap when width exceeds maxHeight or meet a `newline` group
19628 if (nextY > maxHeight || child.newline) {
19629 x += currentLineMaxSize + gap;
19630 y = 0;
19631 nextY = moveY;
19632 currentLineMaxSize = rect.width;
19633 }
19634 else {
19635 currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
19636 }
19637 }
19638
19639 if (child.newline) {
19640 return;
19641 }
19642
19643 position[0] = x;
19644 position[1] = y;
19645

Callers

nothing calls this directly

Calls 3

eachChildMethod · 0.80
childAtMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected