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

Function refixTooltipPosition

src/component/tooltip/TooltipView.ts:1117–1148  ·  view source on GitHub ↗
(
    x: number, y: number,
    content: TooltipHTMLContent | TooltipRichContent,
    viewWidth: number, viewHeight: number,
    gapH: number, gapV: number
)

Source from the content-addressed store, hash-verified

1115}
1116
1117function refixTooltipPosition(
1118 x: number, y: number,
1119 content: TooltipHTMLContent | TooltipRichContent,
1120 viewWidth: number, viewHeight: number,
1121 gapH: number, gapV: number
1122) {
1123 const size = content.getSize();
1124 const width = size[0];
1125 const height = size[1];
1126
1127 if (gapH != null) {
1128 // Add extra 2 pixels for this case:
1129 // At present the "values" in default tooltip are using CSS `float: right`.
1130 // When the right edge of the tooltip box is on the right side of the
1131 // viewport, the `float` layout might push the "values" to the second line.
1132 if (x + width + gapH + 2 > viewWidth) {
1133 x -= width + gapH;
1134 }
1135 else {
1136 x += gapH;
1137 }
1138 }
1139 if (gapV != null) {
1140 if (y + height + gapV > viewHeight) {
1141 y -= height + gapV;
1142 }
1143 else {
1144 y += gapV;
1145 }
1146 }
1147 return [x, y];
1148}
1149
1150function confineTooltipPosition(
1151 x: number, y: number,

Callers 1

_updatePositionMethod · 0.85

Calls 1

getSizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…