D3.js force directed graph, each group different color?

前端 未结 5 1403
小蘑菇
小蘑菇 2021-01-12 11:27

I\'ve made a force directed graph with d3.js plugin, and I wanna color the nodes and the labels with the different color according to group which they belong.

I\'ve

5条回答
  •  迷失自我
    2021-01-12 11:47

    Did you ever solve this? if not a possible solution is here: http://jsfiddle.net/adeaver/F2fbu/1/

    Each group/node is differently colored along with the corresponding text by adding: .style("fill", function(d) { return color(d.group); }) to the text append and group: link.group to the function that computes the nodes from the links

提交回复
热议问题