I am trying to select a branch of my tree and assign each (parent and two levels of children) a unique color. In my example picture below, parent nodes on the right and leafnodes on the left.
My hierarchical data is three levels deep (name:"Specialty" >> name:"Location" >> LeafNode Containing "Provider", "Location", "Specialty"). I'm thinking I need to check each LeafNode object as the path is drawn -
d.source.children.children.children.Specialty == d.source.children.name
but can't put this together to get it to work. As I draw the paths how might I assign a unique color to each branch?
var link = canvas.selectAll(".link")
.data(links)
.enter().append("path")
.attr("d", diagonal)
.attr("stroke-width", 1)
.attr("fill", "none")
.attr("stroke", function(d){
return color(d.target.name == d.target.name ? d : "#111" ); //<< huh?
})