Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ysapiyev
Responsive Resident
Responsive Resident

Absolute position of tooltips

Hi everyone,

 

I have custom visual with vertical scroll bar. And tooltips are positioned by coordinates of elements, therefore some tooltips are at the bottom of the screen or lower How tooltips can be positioned by absolute coordinates?

 

Regards,

Yerkhan

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

We would recommend to use the following code snippet:

// rootNode - root DOM element
// e - is mouse event

let rect = rootNode.getBoundingClientRect();
let coordinates = [e.clientX - rect.left - rootNode.clientLeft, e.clientY - rect.top - rootNode.clientTop];

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

6 REPLIES 6
v-viig
Community Champion
Community Champion

Do you use Tooltip API? If so, you need to get the absolute postion of the element without scrolling using JavaScript.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

 

I've tried using this:

var e = window.onmousemove;

                    var posX = e.clientX;
                    var posY = e.clientY;

However, it doesn't work. How it can be done?

 

Regards,

Yerkhan

v-viig
Community Champion
Community Champion

We would recommend to use the following code snippet:

// rootNode - root DOM element
// e - is mouse event

let rect = rootNode.getBoundingClientRect();
let coordinates = [e.clientX - rect.left - rootNode.clientLeft, e.clientY - rect.top - rootNode.clientTop];

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Anonymous
Not applicable

I have a flow map visual in which tooltips are overflowing out of page.

 

let rect = rootNode.getBoundingClientRect();
let coordinates = [e.clientX - rect.left - rootNode.clientLeft, e.clientY - rect.top - rootNode.clientTop];

 

Will the above code work and where should i exactly put this code to work ?

v-viig
Community Champion
Community Champion

I think so. You should add this code to a function that generates coordinates for Tootip Service.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

Thanks! It helped.

 

Regards,

Yerkhan

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.