Skip to content

Commit

Permalink
fix(legacy-plugin-chart-sankey): ensure tooltip position is within ch…
Browse files Browse the repository at this point in the history
…art (apache#1092)
  • Loading branch information
serenajiang authored and zhaoyongjie committed Nov 24, 2021
1 parent 1e48622 commit e301e9d
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ function Sankey(element, props) {
tooltip
.html(() => getTooltipHtml(d))
.transition()
.duration(200)
.style('left', `${d3.event.offsetX + 10}px`)
.style('top', `${d3.event.offsetY + 10}px`)
.duration(200);
const { height: tooltipHeight, width: tooltipWidth } = tooltip.node().getBoundingClientRect();
tooltip
.style('left', `${Math.min(d3.event.offsetX + 10, width - tooltipWidth)}px`)
.style('top', `${Math.min(d3.event.offsetY + 10, height - tooltipHeight)}px`)
.style('position', 'absolute')
.style('opacity', 0.95);
}
Expand Down

0 comments on commit e301e9d

Please sign in to comment.