正如我可以做的那样,将GoJS中所有在线组合在一起的元素放在一起,而不是当前出现的那些元素,所以我想:
S - > A - > B - > E
但实际上看起来像这样:
S - >甲
B - > E
好吧,我把这个例子放在jsFiddle,中,非常感谢你的帮助。
// Groups consist of a title in the color given by the group node data
// above a translucent gray rectangle surrounding the member parts
myDiagram.groupTemplate =
$(go.Group, "Horizontal",
{ selectionObjectName: "PANEL", // selection handle goes around shape, not label
ungroupable: true }, // enable Ctrl-Shift-G to ungroup a selected Group
$(go.TextBlock,
{
font: "13px sans-serif",
isMultiline: false, // don't allow newlines in text
editable: true // allow in-place editing by user
},
new go.Binding("text", "text").makeTwoWay(),
new go.Binding("stroke", "color")),
$(go.Panel, "Auto",
{ name: "PANEL" },
$(go.Shape, "Process", // the rectangular shape around the members
{ fill: "#FFF", stroke: "#333", strokeWidth: 1, width: 400 }),
$(go.Placeholder, { padding: 10 }) // represents where the members are
),
{ // this tooltip Adornment is shared by all groups
toolTip:
$(go.Adornment, "Auto",
$(go.Shape, { fill: "#FFFFCC" }),
$(go.TextBlock, { margin: 4 },
// bind to tooltip, not to Group.data, to allow access to Group properties
new go.Binding("text", "", groupInfo).ofObject())
)
}
);
答案 0 :(得分:3)
在群组中使用GridLayout:
myDiagram.groupTemplate =
$(go.Group, "Horizontal",
{ selectionObjectName: "PANEL", // selection handle goes around shape, not label
ungroupable: true,
layout: $(go.GridLayout)
},
此外,为了使布局中的节点居中,您可以将locationSpot设置为居中:
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{ locationSpot: go.Spot.Center },
请注意,S和E节点由于它们的定义而很高,所以看起来它们偏离中心但它们不是(选择它们看看我的意思)