Here is my diagram layout:
let myDiagram =
$(go.Diagram,
{
layout: $(go.LayeredDigraphLayout,
{
// for layout options, see https://gojs.net/latest/api/symbols/LayeredDigraphLayout.html
layerSpacing: 5,
columnSpacing: 5,
direction: 90
}),
initialAutoScale: go.Diagram.UniformToFill,
allowCopy: false,
allowDelete: false,
// feedback that dropping in the background is not allowed
mouseDragOver: function (e) {
e.diagram.currentCursor = "not-allowed";
},
"undoManager.isEnabled": true,
maxSelectionCount: 1, // no more than 1 element can be selected at a time
contentAlignment: go.Spot.Center,
});
And here is my group:
return $(go.Group, "Auto",
{ // define the group's internal layout
layout: $(go.LayeredDigraphLayout,
{
layerSpacing: 30,
columnSpacing: 30,
direction: 90
}),
toolTip: nodeToolTip,
// the group begins unexpanded;
// upon expansion, a DiagramWrapper Listener will generate contents for the group
isSubGraphExpanded: false,
// when a group is expanded, if it contains no parts, generate a subGraph inside of it
subGraphExpandedChanged: function(group) {
// When group is expanded, hide the original group node; restore it upon collapse
var shp;
if (group.isSubGraphExpanded){
shp = group.findObject(NodeConstants.NODE_SHAPE);
if (shp != null) {
shp.opacity = 0;
}
shp = group.findObject(NodeConstants.NODE_TEXT);
if (shp != null) {
shp.opacity = 0;
}
} else {
shp = group.findObject(NodeConstants.NODE_SHAPE);
if (shp != null) {
shp.opacity = 1;
}
shp = group.findObject(NodeConstants.NODE_TEXT);
if (shp != null) {
shp.opacity = 1;
}
group.opacity = 1;
}
myDiagram.zoomToFit();
}
},