getRelativeCoordinate
Computes relative element coordinates from mouse or touch event. The output coordinates are relative to the top-left corner of the active element (= currentTarget), where the top-left corner is (0, 0). Moving right, the x-coordinate increases, and moving down, the y-coordinate increases. The coordinates are rounded to the nearest integer and account for CSS transform scale. So element that's scaled will return the same coordinates as element that's not scaled. In other words: you zoom in or out, numbers stay the same. This function works with both HTML elements and SVG elements. It works with both Mouse and Touch events. For Touch events, it returns an array of coordinates, one for each touch point. For Mouse events, it returns a single coordinate object. Available since Recharts 3.8
Return value
RelativePointer
Coordinates relative to the top-left corner of the element. Single object for Mouse events, array of objects for Touch events.
Props
eventHTMLMousePointer | SVGMousePointer
The mouse or touch event from React event handlers (works with both HTML and SVG elements)