I am using the the code found here: http://bl.ocks.org/1249394 for this tree diagram.
How do I change the the size of the root node only? I want the root node to have a different size than all the child nodes. How do I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically you need a property that you can use to tell the nodes apart. Looks like there is an existing parent property that can be used to figure out when a
nodeis theroot. So you just need to change the append functions to modify the radius of the circle if the node has no parent (that is, it is the root).You can see a working example at http://bl.ocks.org/3767443.
In general, if you want to modify particular nodes you can add a new property to nodes that you want to be different like this:
You can then use this property to modify the node as it’s being appended (here I’m modifying the circle, but you can do the same for the text as it is added). Notice that instead of hard coding the size of the circle to 4.5, I’m now using the
rootproperty to make root nodes larger.If you also set the class like I did above, then you can use CSS to style your root node however you want: