Skip to content

Commit

Permalink
Fixes an issue where the tooltip would be too far offset on higher DP…
Browse files Browse the repository at this point in the history
…I screens (#97184)
  • Loading branch information
j6ll authored Dec 6, 2024
1 parent e11e16c commit d7a9293
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function tooltip(
const { left } = u.over.getBoundingClientRect();
const mouseLeft = e.clientX - left;
const activePoint = u.posToIdx( mouseLeft );
const scaleFactor = window.devicePixelRatio || 1;

// If a point is active, update the tooltip
if ( activePoint >= 0 && tooltipRef.current ) {
Expand All @@ -44,9 +45,9 @@ export function tooltip(
return;
}

// Find where that is on the page
const xPos = Math.round( u.valToPos( xPoint, 'x', true ) );
const yPos = Math.round( u.valToPos( yPoint, 'y', true ) );
// Find where that is on the page, adjust for High DPI
const xPos = Math.round( u.valToPos( xPoint, 'x', true ) ) / scaleFactor;
const yPos = Math.round( u.valToPos( yPoint, 'y', true ) ) / scaleFactor;

// Get the date / data value
const date = u.data[ 0 ][ activePoint ];
Expand Down

0 comments on commit d7a9293

Please sign in to comment.