Placing labels of links in own layer

Hi,

I want to make a graph with nodes, links betweens nodes, and labels on the links. However, all three types should be placed in there own layer.

However, when following the standard way of defining a link, I cannot place the textbox in its own layer since the link is a single part.

How can I place the textbox in a different layer?

Cheers,

-Paul.

What is your goal? Do you want to be able to change the visibility or z-ordering or something else? (I'm talking about the link labels relative to all of the Nodes and all or the Links.)

I assume you already know how to control the visibility and/or z-ordering of all Links and of all Nodes, by assigning Part.layerName to different named Layers and then either setting Layer.visible or changing the order of the layers in the diagram.

Oh, and did you really mean “textbox”, used when editing, or did you mean “textblock”, just a TextBlock GraphObject in the Link?

I want to have the labels of the edges in front of all edges, even if the edges cross each other. So I think the labels should be in a different layer.

See reply

One way to do it would be to use label Nodes. See the http://gojs.net/latest/samples/linksToLinks.html sample for a more common way to use Nodes that are labels on Links.

I have modified the State Chart sample to change the label used in its link template to be a separate category of node. That requires moving the state from the link data object to the new node data object, and having the link have a reference to the label node (in an Array, since one could have more than one label node). I also set LinkingTool.archetypeLabelNodeData so that when the user draws a new link a new label node is automatically created and added to the model along with the new link data object. A similar change had to be made to the addNodeAndLink function, which goes through the process of creating a new link more explicitly. The modified State Chart sample is http://gojs.net/temp/stateChartLabelNodes.html.