MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getLayoutRect

Function getLayoutRect

libs/echarts/echarts.simple.js:19713–19807  ·  view source on GitHub ↗

* Parse position info. * * @param {Object} positionInfo * @param {number|string} [positionInfo.left] * @param {number|string} [positionInfo.top] * @param {number|string} [positionInfo.right] * @param {number|string} [positionInfo.bottom] * @param {number|string} [positionInfo.width] * @param

(
    positionInfo, containerRect, margin
)

Source from the content-addressed store, hash-verified

19711 * @return {module:zrender/core/BoundingRect}
19712 */
19713function getLayoutRect(
19714 positionInfo, containerRect, margin
19715) {
19716 margin = normalizeCssArray$1(margin || 0);
19717
19718 var containerWidth = containerRect.width;
19719 var containerHeight = containerRect.height;
19720
19721 var left = parsePercent$1(positionInfo.left, containerWidth);
19722 var top = parsePercent$1(positionInfo.top, containerHeight);
19723 var right = parsePercent$1(positionInfo.right, containerWidth);
19724 var bottom = parsePercent$1(positionInfo.bottom, containerHeight);
19725 var width = parsePercent$1(positionInfo.width, containerWidth);
19726 var height = parsePercent$1(positionInfo.height, containerHeight);
19727
19728 var verticalMargin = margin[2] + margin[0];
19729 var horizontalMargin = margin[1] + margin[3];
19730 var aspect = positionInfo.aspect;
19731
19732 // If width is not specified, calculate width from left and right
19733 if (isNaN(width)) {
19734 width = containerWidth - right - horizontalMargin - left;
19735 }
19736 if (isNaN(height)) {
19737 height = containerHeight - bottom - verticalMargin - top;
19738 }
19739
19740 if (aspect != null) {
19741 // If width and height are not given
19742 // 1. Graph should not exceeds the container
19743 // 2. Aspect must be keeped
19744 // 3. Graph should take the space as more as possible
19745 // FIXME
19746 // Margin is not considered, because there is no case that both
19747 // using margin and aspect so far.
19748 if (isNaN(width) && isNaN(height)) {
19749 if (aspect > containerWidth / containerHeight) {
19750 width = containerWidth * 0.8;
19751 }
19752 else {
19753 height = containerHeight * 0.8;
19754 }
19755 }
19756
19757 // Calculate width or height with given aspect
19758 if (isNaN(width)) {
19759 width = aspect * height;
19760 }
19761 if (isNaN(height)) {
19762 height = width / aspect;
19763 }
19764 }
19765
19766 // If left is not specified, calculate left from right and width
19767 if (isNaN(left)) {
19768 left = containerWidth - right - width - horizontalMargin;
19769 }
19770 if (isNaN(top)) {

Callers 2

echarts.simple.jsFile · 0.70
getViewRectFunction · 0.70

Calls 1

parsePercent$1Function · 0.70

Tested by

no test coverage detected