I’m currently attempting to use groups for a diagram I’m creating.
Every node within the diagram has ‘isGroup’ set to true, and is assigned to an ‘OfGroups’ category for templating. The idea is that these groups can go as many levels down as the user would like them too, however when I move one node/group into another the positioning is incorrect and I’m not quite sure what I’m doing wrong.
This is an example of 3 separate nodes/groups.
I move the ‘User’ node/group into the ‘Requirement’ node:
And then I try to move the ‘Principle’ node/group into ‘Requirement’ as well:
As you can see it doesn’t line up or sit within the group very well…
My group template is as follows:
oDiagram.groupTemplateMap.add('OfGroups',
goJs(go.Group, go.Panel.Auto, {
mouseDragEnter: fGroupMouseDragEnter,
mouseDragLeave: fGroupMouseDragLeave,
computesBoundsAfterDrag: false,
mouseDrop: function () {
fFinishDrop.apply(that, arguments);
},
layout: goJs(go.GridLayout, {
wrappingColumn: 1,
alignment: go.GridLayout.Position,
cellSize: new go.Size(1, 1),
spacing: new go.Size(4, 4)
})
},
new go.Binding('location', 'loc', go.Point.parse),
goJs(go.Panel, go.Panel.Vertical,
goJs(go.Panel, go.Panel.Horizontal, {
stretch: go.GraphObject.Horizontal,
height: 20
},
goJs(go.TextBlock, {
alignment: go.Spot.Left,
font: 'bold 10pt helvetica, bold arial, sans-serif'
},
new go.Binding('text', 'text')
),
goJs(go.Placeholder, {
alignment: go.Spot.Center,
padding: new go.Margin(0, 5)
}),
goJs(go.Shape, {
alignment: go.Spot.Right,
name: 'shape',
strokeWidth: 2,
desiredSize: new go.Size(20, 20)
},
new go.Binding('fill', 'colour'),
new go.Binding('geometryString', 'geoString'),
new go.Binding('stroke', 'stroke')
)
),
goJs(go.Placeholder, {
padding: 10,
alignment: go.Spot.Center
},
new go.Binding('background', 'isHighlighted', function (b) {
return b ? 'red' : 'transparent';
}).ofObject()
)
),
goJs(go.Shape, 'RoundedRectangle', {
isPanelMain: true,
fill: null,
stroke: 'black',
strokeWidth: 2
})
)
);
Any idea what could be causing this?
Thanks