문제

I am trying to get a tree layout for a data set in which i have nodes which can have multiple parents. The links that are created in such instances have extremely large path values. is there anyway to overcome this. I can create a force layout but the tree layout feels more structured and natural to the problem in hand.

Any help is much appreciated.

도움이 되었습니까?

해결책

If you've got multiple parents, you don't really have a tree structure. A network layout is your best option. Here is an example of a a force layout with constraints. In that case I've forced the x-values to specific values. You could do something similar using the tree level to set your x or y value.

The relevant code is:

var adjust_x = function(d) {
  return x(d.time);
};

force.on("tick", function () {
    link.attr("x1", function (d) {
        return adjust_x(d.source);
    }) // snipped remainder...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top