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
Your group info is only available in the links
object, like @ckersch already pointed out. You would need to add the group info to you nodes
object too. For this example that can be done by changing line 16 into:
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target, group: link.group});
But for more complex data, with more than one source
, all sources would have the same colour (or would that be OK?).
I made that change in this Fiddle: http://jsfiddle.net/WBkw9/19/.