I’m using one of your sample with some changes:
diagram.initialContentAlignment = go.Spot.Center;
diagram.groupTemplate =
$(go.Group, "Auto",
$(go.Shape, "Rectangle",
{ fill: "gold" }),
$(go.Panel, "Vertical",
{ margin: 5, defaultAlignment: go.Spot.Left },
$(go.Panel, "Table",
{ alignment: go.Spot.Top, stretch: go.GraphObject.Fill, background: "#fceed1" },
$(go.RowColumnDefinition, { column: 0, width: 16 }),
$("SubGraphExpanderButton",
{ row: 0, column: 0, margin: new go.Margin(0, 0, 0, 3)
}),
$(go.TextBlock, {row: 0, column: 1, font: "14px Sans-Serif", margin: new go.Margin(4, 20, 4, -12), stroke: "#a8863b"}, "Center me!")
),
$(go.Placeholder, { padding: 10 })
)
);
diagram.model = new go.GraphLinksModel(
[ { key: 0, isGroup: true },
{ key: 1, group: 0 },
{ key: 2, group: 0 },
{ key: 3, group: 0 } ] );
That’s how I’ve reached centering of the title. And it works. But if I add placeholder
to make it a little bit prettier
$(go.Placeholder, { padding: 10 })
It breaks. When I collapse group, group takes place only for this padding and hides the title.
Is it a bug? And more general question is how can I center the title and keep it centered in both collapsed and expanded states of the group?