@mui/x-charts
Version:
The community edition of MUI X Charts components.
18 lines (17 loc) • 651 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSurfacePoint = getSurfacePoint;
/**
* Transform mouse event position to coordinates inside the SVG surface or the layer container.
* @param element The SVG surface or the layer container
* @param event The mouseEvent to transform
*/
function getSurfacePoint(element, event) {
const rect = element.getBoundingClientRect();
const style = getComputedStyle(element);
const transform = new DOMMatrix(style.transform);
const point = new DOMPoint(event.clientX - rect.left, event.clientY - rect.top);
return point.matrixTransform(transform.inverse());
}