Skip to content

Commit

Permalink
modified tooltips display conditions to display tooltip for nearest d…
Browse files Browse the repository at this point in the history
…atapoint from left

Signed-off-by: Tarek Quao <[email protected]>
  • Loading branch information
tarekquao committed Dec 3, 2024
1 parent 8ea9783 commit 5936b8a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ export default (): NearbyTip => {
)
return null;

return Math.sqrt(
Math.pow((xScale(v[xValueName]) as number) - pos.x, 2) +
Math.pow(scale(v[yValueName]) - pos.y, 2)
);
const xDist = (xScale(v[xValueName]) as number) - pos.x;
const yDist = scale(v[yValueName]) - pos.y;

if (xDist <= 0 && yDist <= 0) {
return Math.sqrt(
Math.pow(xDist, 2) +
Math.pow(yDist, 2)
);
}
};
};

Expand Down

0 comments on commit 5936b8a

Please sign in to comment.