React hook that keeps track of the point being hovered in a chart, used in ChartOverlayX. Given a timeseries, it returns the component's onMouseMove, onMouseLeave, and hoveredPoint (the point in the timeseries closest to the date being hovered.
onMouseMove
onMouseLeave
hoveredPoint
const { hoveredPoint, onMouseMove, onMouseLeave } = useHoveredDate(timeseries);return ( <svg width={width} height={height}> <LineChart {...lineChartProps} /> {hoveredPoint && ( <Tooltip point={hoveredPoint}> <CircleMarker /> </Tooltip> )} <ChartOverlayX onMouseMove={onMouseMove} onMouseLeave={onMouseLeave} {...otherProps} /> </svg>);
The hovered point information and the onMouseMove and onMouseLeave callbacks.
A timeseries of points that can be hovered, or undefined.
Callback fired when the cursor moves over the overlay.
The date being hovered.
Generated using TypeDoc
React hook that keeps track of the point being hovered in a chart, used in ChartOverlayX. Given a timeseries, it returns the component's
onMouseMove
,onMouseLeave
, andhoveredPoint
(the point in the timeseries closest to the date being hovered.Example
Returns
The hovered point information and the
onMouseMove
andonMouseLeave
callbacks.