How can I get the coordinates of a rectangular DOM element?

188 Views Asked by At

I am trying to draw a graph using D3 where the nodes are rectangular. Then, for some reason, I need to find out the coordinates of those drawn nodes to draw the edges between the nodes. How can I get the coordinates of these rectangular nodes? I have tried doing this:

var ID = d3.select("#node_1")
                 .getBoundingClientRect()
                 .data(graph.nodes);

Here, I am using d3.select("#node_1") for selecting the particular node with ID node_1. But this getBoundingClientRect() does not seem to work in this case. What should I do?

0

There are 0 best solutions below