d3.js - How I can obtain the absolute positions (top and left) of a d3js item? -


hello wanted position of node or text of d3js submit popup position, thanks. have this:

                                nodeenter.append("a")                                         .attr("xlink:href", function (d) {                                             return d.path;                                         })                                         .style("text-decoration", "none")                                         .style("display", function (d) {                                            return (d.name == node_info.name && d.not_beneficially_held == "true") ? "block" : "none";                                         })                                                                         .append("text")                                         .attr("x", function (d) {                                             return (d == root) ? 17 : 15;                                         })                                         .attr("y", function (d) {                                             return (d == root) ? 21 : 25;                                         })                                         .attr("text-anchor", function (d) {                                             return d.children || d._children ? "end" : "start";                                         })                                         .text(function (d) {                                             return "$";                                         })                                         .style("fill", function (d) {                                             return "#4682b4";                                         })                                         .on('click', function (d) {                                             action_click = true;                                                                                    $('#popup_paid').fadein('slow');                                             $('.popup-overlay').fadein('slow');                                             return false;                                         })                                         .on('mouseout', function (d) {                                             d3.selectall("a").remove();                                         }); 

and code or offset jquery not work me:

                function getabsoluteelementposition(element) {                   if (typeof element == "string")                     element = document.getelementbyid(element)                    if (!element) return { top:0,left:0 };                                         var y = 0;                   var x = 0;                   while (element.offsetparent) {                     x += element.offsetleft;                     y += element.offsettop;                     element = element.offsetparent;                   }                   return {top:y,left:x}; 

var pos = getabsoluteelementposition(element);

when normal html if works perfectly.

thanks in advance , greetings


Comments