Node static position

i m working on a diagram there is a node in m y diagram with a templatemap “rootnode” i need that ode to be always present in the upper right corner over every thing and stay there even if the diagram is zoomed or moved

like the node imported physical model should stick to top right for ever

https://gojs.net/latest/intro/legends.html#StaticParts

i tried using this but the node disappears if i give it grid layer

myDiagram.nodeTemplateMap.add(rootNodeLabel, Go(go.Node, "Auto", {
      _viewPosition: new go.Point(0,0),
      //layerName: "Grid",
        deletable: false
      }, new go.Binding("textEditable", "readOnly"),
      // new go.Binding("allowDelete",
      // "foreignKey",function(v){if(v==true){return false;}else
      // {return
      // true;}}),
      Go(go.Shape, "RoundedRectangle", {
        parameter1: 20, // the corner has a large radius
        fill: Go(go.Brush, "Linear", {
          0: "rgb(254, 201, 0)",
          1: "rgb(254, 162, 0)"
        }),
        stroke: "black",
        portId: "",
        fromLinkable: false,
        fromLinkableSelfNode: false,
        fromLinkableDuplicates: false,
        toLinkable: false,
        toLinkableSelfNode: false,
        toLinkableDuplicates: false,
        cursor: "pointer"
      }), Go(go.TextBlock, {
        font: "bold 11pt helvetica, bold arial, sans-serif",
        editable: false
        // editing the text automatically updates
        // the model data
      }, new go.Binding("text", "text").makeTwoWay()), {
        selectionAdornmentTemplate: Go(go.Adornment, "Spot", Go(go.Panel,
            "Auto",
            // this Adornment has a rectangular blue Shape around the
            // selected
            // node
            Go(go.Shape, "Rectangle", {
              fill: null,
              stroke: "black",
              strokeWidth: 1
            }), Go(go.Placeholder))
          // and this Adornment has a Button to the right of the
          // selected node
        )
        // end Adornment
      }

    ));

this is what i m using as template and the listener is the same as the static part topic

First, please read about the “Grid” layer: GoJS Layers -- Northwoods Software. The user cannot select Parts that are in the “Grid” layer, so you don’t need to worry about the user deleting it.

Second, if there are not supposed to be any links connecting with this special Part, don’t have it be a Node – have it be a Part instead. Then you can ignore all properties having to do with nodes and links.

Third, what do you mean that it disappears? Check its Part.location and its Part.position – are they both Points with the x and y values that you wanted, and are they such that the Part is within the Diagram.viewportBounds?

Fourth, please read the “ViewportBoundsChanged” DiagramEvent listener code carefully. Note how it requires the special Part to be simple Part, not a Node.

for the first point -> i m looking into it

for the second point ->user is not allowed to draw any links manually but the program itself draws link on “externalobjectdropped” event so it needs to be a node for my back-end processing

as for third -> this happens


the node that had the grid layer is no more in the diagram

as for fourt -> i need it to work for node is it possible?

You don’t say the value of its Part.position. I bet it’s (NaN, NaN).

Change the code to find that one Node (if there might be any Links connecting with it, it has to be a Node, not a Part) and then assign its position to have what you want relative to the Diagram.viewportBounds.

with or without the layer property set to grid the position of the node is nan,nan but it is visible in the without layer scenario


this is the screenshot with no layer assigned

i got the position from when it is visible now how do i set it to be on top right

Understand the code at GoJS Legends and Titles -- Northwoods Software