Custom link widths based on depth or parent radius

2019-08-14 14:15发布

I have been trying to chase this problem for quite some time. I am trying to adjust the width of an edge based on either the radius of the parent or the depth of the child. Ideally I would like to do it by referencing the parent/source radius. The most promising option has been to create a function for the stroke width:

.attr("stroke-width",  function(d) { return d.r ;}); 

The result is the image below in which one edge is given the desired edge and the rest are different. Is there another method that can be suggested?

Lars Kotthoff suggested the following, but the results are essentially the same:

function(d) { return (d.children ? d.children[0].r : d.r)/600; }

Another option is referencing d.depth but this produces the same results.

enter image description here

When I set the width to d.depth, unusual numbers are returned that do not correspond to the depth. The first edge returns a width of 0, the second returns 1, the third returns 2, and the fourth returns 2 again. There seems to be no rhyme or reason.

    .attr("stroke-width", function(d) { return d.depth});

enter image description here

0条回答
登录 后发表回答