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

Tooltip window positioned incorrectly when zoomed #218

Open
marcprux opened this issue Jan 1, 2019 · 10 comments
Open

Tooltip window positioned incorrectly when zoomed #218

marcprux opened this issue Jan 1, 2019 · 10 comments
Labels

Comments

@marcprux
Copy link
Member

marcprux commented Jan 1, 2019

When zooming into a visualization in Safari 12.0.2 on macOS 10.14.2, the tooltip window is not displayed at the mouse cursor location. If zoomed in enough, the tooltip window does not appear at all (probably because it is "off-screen"). This happens with both the SVG and Canvas renderers.

tooltip

@domoritz
Copy link
Member

domoritz commented Jan 1, 2019

Can you check where the positions are coming from? This may be a Vega issue.

@domoritz
Copy link
Member

domoritz commented Jan 1, 2019

I don't see this issue in Chrome.

@marcprux
Copy link
Member Author

marcprux commented Jan 1, 2019

I don't see it on Chrome either, nor on Firefox (although FF doesn't have pinch-zoom anyway).

@marcprux
Copy link
Member Author

marcprux commented Jan 2, 2019

The problem isn't due to zooming, it is due to scrolling: tooltip positions are correct when zoomed if the scroll position at the upper-leftmost corner. As the document is scrolled, the tooltips start to drift off from the correct location.

It looks like the position is being calculated by https://github.com/vega/vega-tooltip/blob/master/src/position.ts Apparently, event.clientX property in Safari is in page coordinates but in other browsers it is in window coordinates. If I change position.ts to use pageX/pageY instead of clientX/clientY, then it works for me in Safari when zooming, and it continues to work correctly in Chrome and Firefox on macOS (I don't have IE, so I can't test there).

@domoritz
Copy link
Member

domoritz commented Jan 2, 2019

Hmm, that seems to be incorrect when I scroll. See http://localhost:3000/vega-examples.html for example.

@domoritz
Copy link
Member

domoritz commented Jan 2, 2019

screen shot 2019-01-02 at 21 00 20

@marcprux
Copy link
Member Author

marcprux commented Jan 2, 2019

Is that in Chrome or Safari? It would be a shame if we had to check the user-agent and use different logic for the different browsers.

@domoritz
Copy link
Member

domoritz commented Jan 3, 2019

This is in chrome.

@domoritz domoritz added the bug label Jun 25, 2020
@micahfay
Copy link

I'm having a similar issue when used with a vega chart in a scrollable div. The tooltip shows up in the correct place but is referencing the wrong data item. This tooltip is with the cursor over the top most bar. The date should be August 17th.
image

@challet
Copy link

challet commented Jul 7, 2021

I had a similar problem with a vega inside a container with transform: scale(xxx) style. Exploring the call stack, I may have identified a lag between the "inner" coordinates (the one of the scenes, affected by the transform) and the "outer" coordinates (the ones of the canvas mouseover event, related to the client) here.
Switching to the svg render resolved the issue, since the event targets are directly computed by the browser.

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

No branches or pull requests

4 participants