Skip to content

Commit

Permalink
docs:typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Nov 19, 2024
1 parent c69a831 commit 1e80556
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/data/charts/tooltip/generateVirtualElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Helper faking an element bounding box for the Popper.
*/
export function generateVirtualElement(mousePosition) {
if (mousePosition === null) {
return {
getBoundingClientRect: () => ({
width: 0,
height: 0,
x: 0,
y: 0,
top: 0,
right: 0,
bottom: 0,
left: 0,
toJSON: () => '',
}),
};
}
const { x, y } = mousePosition;
const boundingBox = {
width: 0,
height: 0,
x,
y,
top: y,
right: x,
bottom: y,
left: x,
};
return {
getBoundingClientRect: () => ({
...boundingBox,
toJSON: () => JSON.stringify(boundingBox),
}),
};
}

0 comments on commit 1e80556

Please sign in to comment.