Hello, I am trying to combine Arranging layout with the example here:
https://gojs.net/latest/samples/arrowheads.html
My question is, how should I be accessing the “actualCenter” attribute of the primary layout inside of the “LayoutCompleted” DiagramEvent listener. Alternatively, if there is a better/different method I should use to implement the desired node layout.
layout: $(ArrangingLayout,
{ // create a circular arrangement of circular layouts
primaryLayout: $(go.CircularLayout, {
}), // must specify the primaryLayout
arrangingLayout: $(go.CircularLayout, {
spacing: 50,
aspectRatio: .7,
arrangement: go.CircularLayout.ConstantDistance,
nodeDiameterFormula: go.CircularLayout.Circular,
direction: go.CircularLayout.Counterclockwise,
sorting: go.CircularLayout.Forwards
}),
// Uncommenting this filter will force all of the nodes and links to go into the main subset and thus
// will cause all those nodes to be arranged by this.arrangingLayout, here a CircularLayout,
// rather than by the this.sideLayout, which by default is a GridLayout.
filter: function (part) { return true; },
// called for each separate connected subgraph
preparePrimaryLayout: function (lay, coll) { // color all of the nodes in each subgraph
var root = null; // find the root node in this subgraph
coll.each(function (node) {
if (node instanceof go.Node && node.findLinksInto().count === 0) {
root = node;
}
});
},
prepareSideLayout: function (lay, coll, b) { // called once for the sideLayout
// adjust how wide the GridLayout lays out
lay.wrappingWidth = Math.max(b.width, this.diagram.viewportBounds.width);
},
}),
// define a DiagramEvent listener
"LayoutCompleted": function (e) {
// now that the CircularLayout has finished, we know where its center is
var cntr = dia.findNodeForKey("Center");
cntr.location = dia.layout.actualCenter;
}