Si vos données que vous pourriez est vraiment non-hiérarchique, changer la fonction drawCurves de votre exemple en quelque chose comme ceci:
function drawCurves(links) {
d3.select("#plot").selectAll(".link")
.data(links)
.enter()
.append("path")
.attr("class", "link")
.attr("d", function(d){
var lineData = [
{
x: Math.round(d.target.x),
y: Math.round(d.target.y)
}, {
x: Math.round(d.target.x) - Math.round(d.target.x)/3,
y: Math.round(d.target.y) - Math.round(d.target.y)/3
},
{
x: Math.round(d.source.x) - Math.round(d.source.x)/3,
y: Math.round(d.source.y) - Math.round(d.source.y)/3
},{
x: Math.round(d.source.x),
y: Math.round(d.source.y)
}];
return `M${lineData[0].x},${lineData[0].y}C${lineData[1].x},${lineData[1].y},${lineData[2].x},${lineData[2].y},${lineData[3].x},${lineData[3].y} `;
});
}
Pour dessiner les lignes avec l'attribut d, la spécification SVG fournit. Consultez https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d pour plus de référence.
Dans votre exemple http://bl.ocks.org/sjengle/5432087 La fonction drawCurve gère ce cas. voici un violon http://plnkr.co/edit/QR4rL5QlWF5fK3mI1nf8?p=preview – Cyril
Thx! Je me suis retrouvé avec ceci: http://plnkr.co/edit/cVaILhLVwAumWr5QEvSW?p=preview – octameter
[Il est bien de répondre à votre propre question] (http://stackoverflow.com/help/self-answer) avec une explication, si vous avez trouvé une solution. – Anko