-
June 5, 2017 at 9:16 am #7999
Hello,
I have a requirement that the Node has to be resized depending on value. Like the Root Node is the biggest size and the child node is the smallest. Right Now the Node size is relatively sized in such a way the current Node size is depending on the parent and the biggest node size depends on the number of children in branch. Could you please help.
Thanks,
-VijayvizulyJune 5, 2017 at 10:21 am #8000Hello Vijay,
You can override the default node radius settings in a few places. Perhaps the easiest is in the theme file. In src/theme/weightedtree.js you can alter the radius of the nodes in the applyTheme() function
selection.selectAll(".vz-weighted_tree-node circle") .style("stroke",function (d) { return skin.node_stroke(d) }) .style("stroke-opacity",function (d) { return skin.node_stroke_opacity(d) }) .style("fill",function (d) { return skin.node_fill(d) }) .style("fill-opacity", function (d) { return skin.node_fill_opacity(d)});
Just add something like:
.attr("r",function (d) { return myNewRadiusFunction(d));
And you can define myNewRadiusFunction() to use whatever logic you want.
I hope that helps.
Tom
June 5, 2017 at 11:21 am #8001Hi Tom,
Apart from Node Radius, the node path should also be sized relatively. Could you please tell if fixing the node radius will also fix the Node Path size.
Thanks,
-VijayvizulyJune 5, 2017 at 11:31 am #8002Hi Vijay,
Okay, if you want to adjust both of those, then you may want to make the modifications in the core src/viz/weighted_tree.js file. You can modify the function below to use what ever logic you want for both node radius and path thickness, both the circle and links paths use this function to calculate their size.
//Used to calc our node radius for each node based on min/max values per depth. var nodeRadius = function (node) { //Set max size/2 for root node. if (node.depth == 0) return nodeScale.range()[1]/2; nodeScale.domain([minValues[node.depth],maxValues[node.depth]]); return nodeScale(scope.value(node)); }
Cheers,
Tom
-
|
You must be logged in to reply to this topic.