MCPcopy
hub / github.com/nhn/tui.chart / getPositionInRect

Method getPositionInRect

apps/chart/src/component/tooltip.ts:60–86  ·  view source on GitHub ↗
(model: TooltipModel)

Source from the content-addressed store, hash-verified

58 }
59
60 getPositionInRect(model: TooltipModel) {
61 const { target } = model;
62
63 const startX = this.rect.x + model.x;
64 const startY = this.rect.y + model.y;
65 let x = startX + target.radius + target.width + this.offsetX;
66 let y = startY + this.offsetY;
67
68 const { overflowX, overflowY } = this.isTooltipContainerOverflow(x, y);
69 const { width, height } = this.tooltipContainerEl.getBoundingClientRect();
70
71 if (overflowX) {
72 x =
73 startX - (width + target.radius + this.offsetX) > 0
74 ? startX - (width + target.radius + this.offsetX)
75 : startX + this.offsetX;
76 }
77
78 if (overflowY) {
79 y =
80 startY + target.height - (height + this.offsetY) > 0
81 ? startY + target.height - (height + this.offsetY)
82 : y;
83 }
84
85 return { x, y };
86 }
87
88 setTooltipPosition(model: TooltipModel) {
89 const { x, y } = this.getPositionInRect(model);

Callers 1

setTooltipPositionMethod · 0.95

Calls 1

Tested by

no test coverage detected