如何在D3.js的力布局中实现“飞行弧”作为链接

时间:2015-06-18 06:02:12

标签: svg d3.js

请建议如何在d3.JS的力布局中实现飞弧。 与图像enter image description here

中一样

1 个答案:

答案 0 :(得分:1)

做这样的事情 http://fiddle.jshell.net/cyril123/ov1bjrq9/4/

想法是在两个节点之间建立曲线路径。 制作曲线的机制(或路径的d属性)

生活在tick函数内: 您可以根据自己的选择随意更改。

link.attr("d", 
    function(d){
     var s=d.source; 
     var t = d.target;
     return lineFunction([
     {x:s.x, y: s.y},//start point of curve
     {x:(s.x+t.x)/2, y: (s.y+t.y)/2+30}, //middle point of curve
     {x:s.x, y: t.y} ////end point of curve
    ])
    }
);
相关问题