我正在实现 GOJS 图表链接,如下面的链接所示
http://gojs.net/latest/samples/treeMapper.html
我的问题是,如果左侧/右侧的任何元素已经有链接连接,是否可以不允许重复链接?
根据您最初的回答,我更新了 nodeTemplate 的代码,如下所示
myDiagram.nodeTemplate =
$(TreeNode,
{ movable: false }, // user cannot move an individual node
// no Adornment: instead change panel background color by binding to Node.isSelected
{ selectionAdorned: false },
{ fromLinkable: true, toLinkable: true,fromMaxLinks: 1,toMaxLinks:1 }, // user can draw link to and from such tree nodes
$("TreeExpanderButton", // support expanding/collapsing subtrees
{ width: 14, height: 14,
"ButtonIcon.stroke": "black",
"ButtonIcon.strokeWidth": 2,
"ButtonBorder.fill": "whitesmoke",
"ButtonBorder.stroke": "black",
"ButtonBorder.figure": "Rectangle"
}),
$(go.Panel, "Horizontal",
{ position: new go.Point(16, 0) },
new go.Binding("background", "isSelected", function(s) { return (s ? "lightblue" : "white"); }).ofObject(),
$(go.TextBlock,{ font: '9pt Verdana, sans-serif' },
new go.Binding("text", "Data", function(s) { return s; }))
) // end Horizontal Panel
); // end Node
注意:这不仅仅是一个树实现,这是作为记录映射字段的一部分实现的树,如我共享的链接中所示。
也就是说,服务参数的集装箱车与设备模型中的任何其他节点的链接不应超过一个。同样,设备模型中的设备不应有多个来自服务参数的链接。对于所有其他节点也是如此。