Skip to content
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

[@visx/event] Bad svg point calculation in Firefox #1174

Open
vovakulikov opened this issue Apr 17, 2021 · 2 comments
Open

[@visx/event] Bad svg point calculation in Firefox #1174

vovakulikov opened this issue Apr 17, 2021 · 2 comments

Comments

@vovakulikov
Copy link
Contributor

vovakulikov commented Apr 17, 2021

Hi there.

It seems like in Firefox svg.screenCTM() result is a bit different compared to other browsers (Safari, Chrome). More about this here https://bugzilla.mozilla.org/show_bug.cgi?id=1610093

Since @visx/event uses this API to calculate svg point position

const svg = isSVGElement(node) ? node.ownerSVGElement : node;
const screenCTM = isSVGGraphicsElement(svg) ? svg.getScreenCTM() : null;
if (isSVGSVGElement(svg) && screenCTM) {
let point = svg.createSVGPoint();
point.x = coords.x;
point.y = coords.y;
point = point.matrixTransform(screenCTM.inverse());
return new Point({
x: point.x,
y: point.y,
});
}

This all leads us to the case when we translate our chart we get a bad tooltip and cursor line position.

Screenshot 2021-04-17 at 15 17 32

@williaster
Copy link
Collaborator

Thanks for the report @vovakulikov 🙏 Not sure what an ideal fix is for that, open to suggestions/thoughts!

@tschai-yim
Copy link

The bug was fixed in Firefox v126, but the misaligned tooltips / brushes are still a problem when they are used inside a translated svg element. See this example, where I shifted the brush 100 pixels to the right. In Chrome, it works as expected, in Firefox it seems to take the outermost svg element as reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants