Skip to content Skip to sidebar Skip to footer

How To Apply Preferences To A D3.tree Node

I have adapted a code from https://bl.ocks.org/mbostock/4063550 to make a nice figure for the tidy arrangement of layered nodes. Assume I have a similar flare.csv file as on the w

Solution 1:

You can check for parents and children when styling the circles:

node.append("circle")
    .style("fill", function(d) {
        return !d.parent ? "blue" : d.children ? "red" : "black";
    })
    .attr("r", 2.5);

Here is your update bl.ocks: https://bl.ocks.org/anonymous/696c1201ed63715753e76e480db343f0

EDIT: colouring only your specified node:

.style("fill", function(d){
    return !d.parent ? "blue" : d.data.id === "flare.vis.data" ? "red" : "black";
})

Here is the bl.ocks: https://bl.ocks.org/anonymous/b55bc1e54414b4bbbfebee93ac6912a4


Post a Comment for "How To Apply Preferences To A D3.tree Node"