File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,12 @@ export const GraphTooltipWrapper = ({
2121 isTouchDevice ?: boolean
2222} ) => {
2323 const ref = useRef < HTMLDivElement > ( null )
24- // distance from cursor to tooltip edge
25- const offsetFromCursor = 32
24+ // bigger on mobile to have room between thumb and tooltip
25+ const xOffsetFromCursor = isTouchDevice ? 24 : 12
26+ const yOffsetFromCursor = isTouchDevice ? 48 : 24
2627 const [ measuredWidth , setMeasuredWidth ] = useState ( minWidth )
2728 // center tooltip above the cursor, clamped to prevent left/right overflow
28- const rawLeft = x - measuredWidth / 2
29+ const rawLeft = x + xOffsetFromCursor
2930 const tooltipLeft = Math . max ( 0 , Math . min ( rawLeft , maxX - measuredWidth ) )
3031
3132 useLayoutEffect ( ( ) => {
@@ -54,7 +55,7 @@ export const GraphTooltipWrapper = ({
5455 minWidth,
5556 left : tooltipLeft ,
5657 top : y ,
57- transform : `translateY(-100%) translateY(-${ offsetFromCursor } px)`
58+ transform : `translateY(-100%) translateY(-${ yOffsetFromCursor } px)`
5859 } }
5960 >
6061 { children }
Original file line number Diff line number Diff line change @@ -266,7 +266,8 @@ function InnerGraph<T extends ReadonlyArray<number | null>>({
266266 xPointer >= xLeftEdge - hoverBuffer &&
267267 xPointer <= xRightEdge + hoverBuffer &&
268268 yPointer >= yTopEdge - hoverBuffer &&
269- yPointer <= yBottomEdge + hoverBuffer
269+ // chart is interactive even over x-axis labels
270+ yPointer <= height
270271 return { xPointer, yPointer, inHoverableArea }
271272 }
272273 const getClosestIndexToPointer = ( xPointer : number ) : number =>
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ const MainGraphTooltip = ({
321321 maxX = { maxX }
322322 isTouchDevice = { isTouchDevice }
323323 className = {
324- 'absolute select-none pointer-events-none bg-gray-800 dark:bg-gray-950 py-3 px-4 rounded-md z-[100] shadow shadow-gray-200 dark:shadow-gray-850'
324+ 'absolute z-10 select-none pointer-events-none bg-gray-800 dark:bg-gray-950 py-3 px-4 rounded-md shadow shadow-gray-200 dark:shadow-gray-850'
325325 }
326326 >
327327 < aside className = "text-sm font-normal text-gray-100 flex flex-col gap-1.5" >
@@ -407,7 +407,7 @@ export const MainGraphContainer = React.forwardRef<
407407 { children : ReactNode }
408408> ( ( props , ref ) => {
409409 return (
410- < div className = "relative my-4 h-92 w-full z-0 " ref = { ref } >
410+ < div className = "relative my-4 h-92 w-full" ref = { ref } >
411411 { props . children }
412412 </ div >
413413 )
You can’t perform that action at this time.
0 commit comments