问题描述
我想根据节点模板类型设置不同的 linkTemplate 偏移量。
其实我只有一个linkTemplate
dia.linkTemplate =
$(go.Link,// { routing: go.Link.AvoidsNodes },// link route should avoid nodes
$(go.Shape,{ stroke: 'gray',height: 12 }),$(go.TextBlock,'fiber_manual_record',{ font: '20pt Material Icons',stroke: 'gray' },{
segmentIndex: 0,segmentOffset: new go.Point(-9,8),segmentOrientation: go.Link.OrientAlong
}),{ font: '15pt Material Icons',{
segmentIndex: -1,segmentOffset: new go.Point(-1,segmentOrientation: go.Link.OrientAlong
})
);
但我有两个 nodeTemplateMap,每个都有不同的形状。
我的问题是链接不会根据使用的节点在同一级别开始。
解决方法
您可以向链接模板添加绑定,根据节点的类型确定 Link.fromShortLength 或 Link.toShortLength。类似的东西:
$(go.Link,new go.Binding("fromShortLength","fromNode",node => node.category === "A" ? 10 : 20),. . .
)
显然你需要决定如何使用节点来确定Link.fromShortLength的值来使用。