Skip to content

Commit

Permalink
[#848] [3.0] chart tool-tip 위치 계산 이슈
Browse files Browse the repository at this point in the history
- 차트 툴팁의 위치를 정하는 로직에서 특정 값(마우스 위치 <-> 툴팁 위치 사이 값: 20) 이 누락됨
  • Loading branch information
jhee564 committed Jul 28, 2021
1 parent 423509f commit 8440f5f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/components/chart/plugins/plugins.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,19 @@ const modules = {
// set tooltipDOM's positions
const bodyWidth = document.body.clientWidth;
const bodyHeight = document.body.clientHeight;
this.tooltipDOM.style.left = mouseX > bodyWidth - contentsWidth - 20
? `${mouseX - contentsWidth - 20}px`
: `${mouseX + 20}px`;
this.tooltipDOM.style.top = mouseY > bodyHeight - (titleHeight + contentsHeight) - 20
? `${mouseY - (titleHeight + contentsHeight) - 20}px`
: `${mouseY + 20}px`;
const distanceMouseAndTooltip = 20;
const maximumPosX = bodyWidth - contentsWidth - distanceMouseAndTooltip;
const maximumPosY = bodyHeight - (titleHeight + contentsHeight) - distanceMouseAndTooltip;
const expectedPosX = mouseX + distanceMouseAndTooltip;
const expectedPosY = mouseY + distanceMouseAndTooltip;
const reversedPosX = mouseX - contentsWidth - distanceMouseAndTooltip;
const reversedPosY = mouseY - (titleHeight + contentsHeight) - distanceMouseAndTooltip;
this.tooltipDOM.style.left = expectedPosX > maximumPosX
? `${reversedPosX}px`
: `${expectedPosX}px`;
this.tooltipDOM.style.top = expectedPosY > maximumPosY
? `${reversedPosY}px`
: `${expectedPosY}px`;
},

/**
Expand Down

0 comments on commit 8440f5f

Please sign in to comment.