sandip
March 10, 2025, 8:58am
1
LayOut :
layout: $(go.LayeredDigraphLayout,
{
setsPortSpots: true,
direction: 90,
layerSpacing: 65,
columnSpacing: 30,
//isInitial: true,
isOngoing:false,
aggressiveOption: go.LayeredDigraphAggressive.None, // Maintain order within layers
}),
ScreenShot :
walter
March 10, 2025, 9:13am
2
Do you need to use LayeredDigraphLayout for each subnetwork instead of TreeLayout ? It doesn’t really support sorting (but TreeLayout does), so I suggest that you use the ArrangingLayout extension, where the ArrangingLayout.primaryLayout ArrangingLayout | GoJS API is your current desired LayeredDigraphLayout and the ArrangingLayout.arrangingLayout ArrangingLayout | GoJS API is a GridLayout which has GridLayout.sorting and GridLayout.comparer set the way that you want.
sandip
March 10, 2025, 9:36am
3
not compulsory to use LayeredDigraphLayout .
can you give me solution with Treelayout and ArrangingLayout?
I have tried below code but not getting correct sequence :
this.myDiagram.layout = $(ArrangingLayout, {
primaryLayout: $(go.TreeLayout,
{
angle: 90,
layerSpacing: 65,
}), // Layout for connected nodes
arrangingLayout: $(go.GridLayout, {
alignment: go.GridLayout.Position,
arrangement: go.GridArrangement.LeftToRight
}), // Layout for arranging subnetworks
});
walter
March 10, 2025, 10:01am
4
You need to set GridLayout.sorting and comparer .
walter
March 10, 2025, 10:04am
5
If you set TreeLayout.sorting and comparer , you might not need to use ArrangingLayout and GridLayout at all.
sandip
March 10, 2025, 10:14am
6
Is comparer a custom function?
walter
March 10, 2025, 10:17am
7
Yes, the library cannot know how you want to sort, so the function needs to depend on your data. Here’s an example:
new go.Diagram("myDiagramDiv", {
layout: new go.TreeLayout({
sorting: go.TreeSorting.Ascending,
comparer: (v, w) => {
// just compare root nodes/vertices
if (v.parent || w.parent) return 0;
// could compare smarter than just comparing string lengths
return w.node.data.text.length - v.node.data.text.length
}
}),