How to get coordinates of an svg element?

前端 未结 7 2035

I am using d3 to draw a line from a relative svg position and hence want to access the coordinates of the element itself. I tried something like this (where \"this\" refers

7条回答
  •  醉话见心
    2020-12-23 12:07

    I use the consolidate function, like so:

     element.transform.baseVal.consolidate()
    

    The .e and .f values correspond to the x and y coordinates

提交回复
热议问题