Layout LayeredDigraphLayout sort data

Hi!

First question : Is it possible to sort data in layout LayeredDigraphLayout?

Second question : In TreeLayout it is possible to sort by the comparer like this :

function keyCompare(a, b) { var at = a.node.data.category; var bt = b.node.data.category; if (at < bt) return -1; if (at > bt) return 1; return 0; }
The sort is on one property but it is possible to sort on one property then one another?

Cédric

First, not really, since LayeredDigraphLayout is supposed to be able to re-order vertexes in a layer in order to try to reduce the number of link crossings.

Second, sure – just change your comparer function to take all of the data properties that you care about.

OK so in treelayout can i have two fathers for one children?

I ask this question cause in LayeredDigraphLayout it is possible to have this case but it s not possible to sort my data by one property and vice versa.

It does not make sense for a node to have more than one “parent” in a tree structure. However, although TreeLayout is tolerant of such relationships, it is not very accommodating of them.

If you are doing something like http://gojs.net/latest/samples/orgChartExtras.html, you could declare all but one of those “parent” links to be
isLayoutPositioned: false,
isTreeLink: false
which will allow TreeLayout to operate as if the extra parent links were not present, and which will allow Node operations on trees to ignore those extra links.