add different shapes to d3 force layout

狂风中的少年 提交于 2019-12-05 23:58:21
Walter Roman

I think it would be easier to insert svg paths rather than rects or circles. It's pretty flexible and you'll be able to add just about any shape you can think of to the force graph.

The following code draws a star. http://jsfiddle.net/UkeMS/

<svg>
    <path  d="
        m 100 100
        l 23 12
        l -4 -26
        l 19 -19
        l -27 -4
        l -11 -23
        l -12 23
        l -27 4
        l 19 19
        l -4 26
        l 24 -12
    "/>
</svg>

Just remember to declare the paths using relative coordinates with lowercase letters (as above) as opposed to absolute coordinates using uppercase letters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!