Place pie charts on nodes of force directed layout graph in D3

前端 未结 2 1863
余生分开走
余生分开走 2020-12-10 17:34

I would like to place pie charts on the node of a D3 force directed layout graph using D3.js. This is a common visualization in population genetics, see for example http://m

2条回答
  •  余生分开走
    2020-12-10 18:03

    The problem appears to be the last statement in your force-on-tick callback:

    node.attr("x", function(d) { return d.x; })
        .attr("y", function(d) { return d.y; });
    

    SVG paths have no such x/y attributes. Try translating the path instead:

    node.attr('transform', function(d) { return 'translate(' + d.x + ',' + d.y + ')'; });
    

提交回复
热议问题