Calculate SVG Path Centroid with D3.js

后端 未结 3 1709
野的像风
野的像风 2020-12-05 14:32

I\'m using the SVG located at http://upload.wikimedia.org/wikipedia/commons/3/32/Blank_US_Map.svg in a project and interacting with it with d3.js. I\'d like to create a cli

3条回答
  •  猫巷女王i
    2020-12-05 15:02

    From here

    The solution is to use the .datum() method on the selection.

    var element = d3.select("#element");
    var centroid = path.centroid(element.datum());
    

提交回复
热议问题