[英]Changing the zOrder of a Panel on a Link with GoJS
我正在嘗試配置我的 GoJS 圖(使用 LayeredDiagraphLayout),以便顯示鏈接的 label 的面板(在此示例中顯示百分比)始終位於前景,在圖表上的所有其他項目之前。 目前,它在面板前面顯示了一些鏈接線(如圖所示):
我的目標:
確保顯示百分比的面板始終在其他所有內容之前可見。
到目前為止我嘗試過的:
將鏈接帶入前景層(如此處建議):
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"))
)
);
Assigning a zOrder directly to the go.Panel
, go.Shape
, and go.TextBlock
items seen in the code above, however, all gave errors like this: Uncaught Error: Trying to set undefined property "zOrder" on object: Shape(RoundedRectangle)
. 根據文檔, Part
擴展Panel
,所以我希望我能夠將zOrder
分配給Panel
,但它給出了這個錯誤,所以顯然我的期望是錯誤的。
如何配置此圖表,使鏈接上的面板始終位於前台,因此始終在其他所有內容的前面可見? 謝謝!
有關討論,請參閱https://forum.nwoods.com/t/changeing-zorder-for-panel-on-link-on-layereddiagraphlayout/13714 。
也許這就是你想要的,假設 label 是鏈接的第二個元素:
$(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;
});
},
. . .
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.