Search code examples
portlayervisiblegojs

Is it possible to place a port on a layer so that it is invisible when the layer.visible is set to false?


Is it possible to place a port on a layer so that it is invisible when the layer is not visible? I could not find an answer in GOJS documentation. I tested with this link template and it did not work.

myDiagram.linkTemplate =
        $(CustomLink,  // defined below
          { layerName: "blue",...

Solution

  • You can only put Parts in Layers -- either Nodes or Links or Adornments. In other words, you cannot split up a Node so that a piece of it appears in one layer and another piece of the same Node appears in a different layer.

    The normal thing to do is to show or hide pieces such as ports, either by changing their visible property or their opacity property. The former causes the node's panels to be remeasured and rearranged; the latter does not. Several samples demonstrate this, including the Flow Chart sample.