How to get coordinates of an svg element?

前端 未结 7 2009

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:17

    I was trying to select an area of svg with a rectangle and get all the elements from it. For this, element.getBoundingClientRect() worked perfectly for me. It returns current coordinates of svg elements regardless of whether svg is scaled or transformed.

提交回复
热议问题