【问题标题】:Changing the zOrder of a Panel on a Link with GoJS使用 GoJS 更改链接上面板的 zOrder
【发布时间】:2020-06-03 16:27:54
【问题描述】:

我正在尝试配置我的 GoJS 图(使用 LayeredDiagraphLayout),以使显示链接标签的面板(在此示例中显示百分比)始终位于前景,在图上所有其他项目的前面。目前,它在面板前面显示了一些链接线(如图所示):

我的目标:

确保显示百分比的面板始终显示在其他所有内容的前面。

到目前为止我所做的尝试:

将链接带入前景层(建议here):

myDiagram.linkTemplate =
  $$(go.Link,
    { routing: go.Link.AvoidsNodes, curve: go.Link.JumpGap, corner: 5, layerName:"Foreground" },
    $$(go.Shape, { strokeWidth: 3, stroke: "#555" }),
    $$(go.Panel, "Auto", // this whole Panel is a link label
      $$(go.Shape, "RoundedRectangle", { fill: "lightgray", stroke: "gray" }),
      $$(go.TextBlock, { margin: 3 },
        new go.Binding("text", "ownership"))
    )
  );

zOrder 直接分配给上面代码中看到的go.Panelgo.Shapego.TextBlock 项目,但是,都给出了这样的错误:Uncaught Error: Trying to set undefined property "zOrder" on object: Shape(RoundedRectangle)。根据documentationPart 扩展Panel,所以我希望我能够将zOrder 分配给Panel,但它给出了这个错误,所以显然我的期望是错误的。

如何配置此图表,以使链接上的面板始终位于前台,因此始终在其他所有内容的前面可见?谢谢!

【问题讨论】:

    标签: javascript gojs


    【解决方案1】:

    请参阅https://forum.nwoods.com/t/changing-zorder-for-panel-on-link-on-layereddiagraphlayout/13714 进行讨论。

    也许这就是你想要的,假设标签是链接的第二个元素:

          $(go.Diagram, . . .,
            {
              layout: $(go.LayeredDigraphLayout, { direction: 90, . . . }),
              "LayoutCompleted": function(e) {
                e.diagram.links.each(function(l) { l.elt(1).segmentIndex = -Infinity; });
                e.diagram.nodes.each(function(n) {
                  var outs = n.findLinksOutOf();
                  var ins = n.findLinksInto();
                  if (outs.count === 1) outs.first().elt(1).segmentIndex = 1;
                  else if (ins.count === 1) ins.first().elt(1).segmentIndex = -2;
                });
              },
              . . .
    

    【讨论】:

    • 感谢您在这里回复沃尔特,这就是在您的论坛上提出问题的同一个人。到目前为止,您的帮助非常大,我会尝试您的最新建议并跟进!
    猜你喜欢
    • 2015-09-28
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多