-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TooltipWithBounds overflowing its parent on small screens #466
Comments
Hi @sun-tea, first off, that's a very nice looking chart. Great work! Thanks for reporting this, we can get this fixed in // CustomTooltipWithBounds.js
import React from 'react';
import { Tooltip } from '@vx/tooltip';
import { withBoundingRects } from '@vx/bounds';
function CustomTooltipWithBounds({
left: initialLeft,
top: initialTop,
offsetLeft = 10,
offsetTop = 10,
rect,
parentRect,
getRects,
children,
style,
...otherProps
}) {
let left = initialLeft;
let top = initialTop;
// custom bounds logic implementation
return (
<Tooltip
style={{ top: 0, transform: `translate(${left}px, ${top}px)`, ...style }}
{...otherProps}
>
{children}
</Tooltip>
);
}
export default withBoundingRects(CustomTooltipWithBounds); |
Yep, I was aiming for a solution like this. Thank you for the quick response Harrison, vx is an awesome lib 🙂 |
I'm sorry for the question which is not entirely relevant to this issue, but I was wondering if there was any other workaround other than putting a |
I came up with something like this for preventing horizontal overflow, I am sharing in case it works for somebody else, too:
It limits the horizontal position of the tooltip to the left or right side edge. |
Definitely think there could be more |
Can I work on this? |
@williaster @hshoff should this issue be closed? It seems the PR with a fix #837 has already been merged |
yes! thanks @m0t0r 🙏 |
I use the TooltipWithBounds to display tooltips on vx charts. I noticed that on small screens, the tooltip may overflow if neither left or right of the touch point (I'm on mobile) has enough place to fit the tooltip.
In my case, the left prop thus becomes negative. Maybe we could make the tooltip go above or below the touch point/cursor in these cases ?
The text was updated successfully, but these errors were encountered: