Domanda

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.

È stato utile?

Soluzione

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...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top