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

Method _updatePosition

src/component/tooltip/TooltipView.ts:905–979  ·  view source on GitHub ↗
(
        tooltipModel: Model<TooltipOption>,
        positionExpr: TooltipOption['position'],
        x: number,  // Mouse x
        y: number,  // Mouse y
        content: TooltipHTMLContent | TooltipRichContent,
        params: TooltipCallbackDataParams | TooltipCallbackDataParams[],
        el?: Element
    )

Source from the content-addressed store, hash-verified

903 }
904
905 _updatePosition(
906 tooltipModel: Model<TooltipOption>,
907 positionExpr: TooltipOption['position'],
908 x: number, // Mouse x
909 y: number, // Mouse y
910 content: TooltipHTMLContent | TooltipRichContent,
911 params: TooltipCallbackDataParams | TooltipCallbackDataParams[],
912 el?: Element
913 ) {
914 const viewWidth = this._api.getWidth();
915 const viewHeight = this._api.getHeight();
916
917 positionExpr = positionExpr || tooltipModel.get('position');
918
919 const contentSize = content.getSize();
920 let align = tooltipModel.get('align');
921 let vAlign = tooltipModel.get('verticalAlign');
922 const rect = el && el.getBoundingRect().clone();
923 el && rect.applyTransform(el.transform);
924
925 if (isFunction(positionExpr)) {
926 // Callback of position can be an array or a string specify the position
927 positionExpr = positionExpr([x, y], params, content.el, rect, {
928 viewSize: [viewWidth, viewHeight],
929 contentSize: contentSize.slice() as [number, number]
930 });
931 }
932
933 if (isArray(positionExpr)) {
934 x = parsePercent(positionExpr[0], viewWidth);
935 y = parsePercent(positionExpr[1], viewHeight);
936 }
937 else if (isObject(positionExpr)) {
938 const boxLayoutPosition = positionExpr as BoxLayoutOptionMixin;
939 boxLayoutPosition.width = contentSize[0];
940 boxLayoutPosition.height = contentSize[1];
941 const layoutRect = getLayoutRect(
942 boxLayoutPosition, { width: viewWidth, height: viewHeight }
943 );
944 x = layoutRect.x;
945 y = layoutRect.y;
946 align = null;
947 // When positionExpr is left/top/right/bottom,
948 // align and verticalAlign will not work.
949 vAlign = null;
950 }
951 // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
952 else if (isString(positionExpr) && el) {
953 const pos = calcTooltipPosition(
954 positionExpr, rect, contentSize, tooltipModel.get('borderWidth')
955 );
956 x = pos[0];
957 y = pos[1];
958 }
959 else {
960 const pos = refixTooltipPosition(
961 x, y, content, viewWidth, viewHeight, align ? null : 20, vAlign ? null : 20
962 );

Callers 2

_showAxisTooltipMethod · 0.95
_showTooltipContentMethod · 0.95

Calls 15

getLayoutRectFunction · 0.90
shouldTooltipConfineFunction · 0.90
isArrayFunction · 0.85
calcTooltipPositionFunction · 0.85
refixTooltipPositionFunction · 0.85
isCenterAlignFunction · 0.85
confineTooltipPositionFunction · 0.85
getWidthMethod · 0.65
getHeightMethod · 0.65
isFunctionFunction · 0.50
isObjectFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected