famargar
famargar

Reputation: 3448

Color d3 radial tree according to node property

Similarly to this SO question I would like to build a colored radial tree with d3.js, starting from the example in here. I am a complete newbie in both javascript and d3.

I'd like to make it so that the nodes - and/or the terminal part of the edges - are colored with different intensity according to some property encoded in the original csv. Example would be:

id,value
flare,
flare.analytics,
flare.analytics.cluster,
flare.analytics.cluster.AgglomerativeCluster,3938
flare.analytics.cluster.CommunityStructure,3812
flare.analytics.cluster.HierarchicalCluster,6714
flare.analytics.cluster.MergeEdge,743

where I would like to color nodes depending on "value" This does not work:

node.append("circle")
      .attr("r", 2.5)
      .style('fill', function(d) {
        if (Number(d.value) > Number(4000)){
          return "orange";
        }
      });

Upvotes: 1

Views: 139

Answers (1)

AlbertK
AlbertK

Reputation: 13187

Try to use d.data.value instead of d.value

Upvotes: 1

Related Questions