GoJS 中 Link 上方的图标

Icon Above Link in GoJS

在 GoJS 中,是否可以在 link 上方显示一个图标,这样当 link 移动时,图标也会移动?

例如,我想要看起来像 this 的东西,但是当移动任一节点时,图标也会移动。

当然 - 只需将 GraphObject 添加到您的 link 模板。默认情况下,这样一个 "label"(它不仅需要是 TextBlock,而且可以是任意复杂的 Panel 对象)将是在 link 的中点。您可以设置标签对象的属性来控制它在 link.

路径上的排列位置和方式

类似于:

myDiagram.linkTemplate =
  $(go.Link,
    $(go.Shape),  // the path
    $(go.Shape, { toArrow: "Standard" }),  // the arrowhead
    $(go.Picture, ...,   // your label implemented by a Picture showing an image
      {
        width: ..., height: ...,
        // with this offset relative to the mid point of the link path
        segmentOffset: new go.Point(0, -15)
      })
  );

http://gojs.net/latest/intro/linkLabels.html

阅读更多内容