-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Custom tooltip changing position when scrolling #3995
Comments
You use Instead, if the tooltip is in the same container as the canvas, you should use |
Thanks @simonbrunel it helped. Would it be the case to fix the sample code? I just copied from there. I also needed to add canvas's wrapper top and left, for some reason it was interfering: var canvas = this._chart.canvas;
var canvasContainer = $(canvas).parents('.container')[0];
tooltipEl.style.left = canvas.offsetLeft + canvasContainer.offsetLeft + tooltip.caretX + "px";
tooltipEl.style.top = canvas.offsetTop + canvasContainer.offsetTop + tooltip.caretY + "px"; |
You right, examples need to be fixed. |
hum, I think it does make sense. I let you know when I have a chance to take a look at it again and we can close this issue. |
You right, If I add the element inside the canvas I can have it positioned properly. My problem is that I have two charts on the same page and when I hover over the second chart, the tooltip is positioned based on the first chart. Anyway, I could positioned it properly inserting it on the body no matter how many charts I have on a page. Thanks for your attention. 👍 |
@simonbrunel When you have many charts on the same page the offset values do not position the tooltips properly, especially when you can scroll on the page as well. A simple fix is to make the tooltip element position Codepen: https://codepen.io/anon/pen/YaZNwL |
Expected Behavior
Tooltip should stay on the original position when scrolling.
Current Behavior
Tooltip is changing position when scrolling.
Possible Solution
Steps to Reproduce (for bugs)
Codepen: http://codepen.io/anon/pen/aJBYVR
Gif from my computer:
Context
Environment
The text was updated successfully, but these errors were encountered: