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

Function getBoxPosition

libs/echarts/echarts.simple.js:8843–8884  ·  view source on GitHub ↗
(out, hostEl, style, rect)

Source from the content-addressed store, hash-verified

8841}
8842
8843function getBoxPosition(out, hostEl, style, rect) {
8844 var baseX = style.x || 0;
8845 var baseY = style.y || 0;
8846 var textAlign = style.textAlign;
8847 var textVerticalAlign = style.textVerticalAlign;
8848
8849 // Text position represented by coord
8850 if (rect) {
8851 var textPosition = style.textPosition;
8852 if (textPosition instanceof Array) {
8853 // Percent
8854 baseX = rect.x + parsePercent(textPosition[0], rect.width);
8855 baseY = rect.y + parsePercent(textPosition[1], rect.height);
8856 }
8857 else {
8858 var res = (hostEl && hostEl.calculateTextPosition)
8859 ? hostEl.calculateTextPosition(_tmpTextPositionResult, style, rect)
8860 : calculateTextPosition(_tmpTextPositionResult, style, rect);
8861 baseX = res.x;
8862 baseY = res.y;
8863 // Default align and baseline when has textPosition
8864 textAlign = textAlign || res.textAlign;
8865 textVerticalAlign = textVerticalAlign || res.textVerticalAlign;
8866 }
8867
8868 // textOffset is only support in RectText, otherwise
8869 // we have to adjust boundingRect for textOffset.
8870 var textOffset = style.textOffset;
8871 if (textOffset) {
8872 baseX += textOffset[0];
8873 baseY += textOffset[1];
8874 }
8875 }
8876
8877 out = out || {};
8878 out.baseX = baseX;
8879 out.baseY = baseY;
8880 out.textAlign = textAlign;
8881 out.textVerticalAlign = textVerticalAlign;
8882
8883 return out;
8884}
8885
8886
8887function setCtx(ctx, prop, value) {

Callers 2

renderPlainTextFunction · 0.70
drawRichTextFunction · 0.70

Calls 2

parsePercentFunction · 0.70
calculateTextPositionFunction · 0.70

Tested by

no test coverage detected