Recreating collapsible force layout using d3 v4

前端 未结 1 1371
孤独总比滥情好
孤独总比滥情好 2021-01-20 17:35

I\'ve been trying to create a Collapsible force layout using d3js v4, similar to this one: https://mbostock.github.io/d3/talk/20111116/force-collapsible.html

I\'ve b

相关标签:
1条回答
  • 2021-01-20 18:13

    I forgot to merge old nodes after enter().

    link = svg.selectAll(".link").data(links, function(d) { return d.target.id; })
    var linkEnter = link.enter().append("line").attr("class", "link");
    link = linkEnter.merge(link);
    

    Thanks to Mike Bostock for helping me with this problem. I thought there was an issue with d3 v4, turns out I didn't read changes fully :|

    Refer this for more info: https://github.com/d3/d3-force/issues/37

    Fixed fiddle: https://jsfiddle.net/t4vzg650/6/

    0 讨论(0)
提交回复
热议问题