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 problem is that group
is not defined for your data. As a result, all of your nodes are colored for group 'undefined'. Your circles are defined for the data in force.nodes()
, which have the attributes index
name
px
py
weight
x
and y
. group
is only defined for the links, which never have color applied to them.
As it currently stands, there also isn't a clear way to determine what color a node should be. What happens if more than one link connects to a node, and these links are in different groups?