GoJS API
/ to search
    Preparing search index...

    Class Group

    A Group is a Node that can contain a subgraph of Nodes and Links, which are members of the group.

    For more discussion, see Learn page on Groups. See samples that make use of Groups in the samples index.

    Although you can create a Group and Diagram.add it to a Diagram, this does not update the Model. It is more common to create a group by adding a node data object to the model by calling Model.addNodeData. For example:

      myDiagram.startTransaction("make new group");
    myDiagram.model.addNodeData({ key: "Omega", isGroup: true });
    myDiagram.commitTransaction("make new group");

    This will cause a Group to be created (copying the template found in Diagram.groupTemplateMap), added to the Diagram in some Layer (based on Part.layerName), and bound to the group data (resulting in Panel.data referring to that group data object). Note that the JavaScript object includes setting isGroup to true, to indicate that the object represents a Group rather than a regular Node or simple Part.

    The member Parts of a Group, which you can access as the memberParts collection, belong to the group but are not in the visual tree of the group. All Parts are directly in Layers -- they cannot be inside a Panel. This allows group member parts to be in layers different from the group's layer.

    You can change the membership of a Node or a simple Part in a Group by setting its Part.containingGroup property. This is done automatically for you by the diagram if you initialize the group property on the node data in the model to be the key of the containing group node data. Thus you should do something like:

      myDiagram.startTransaction("add new member");
    myDiagram.model.addNodeData({ group: someExistingGroupKey, ... });
    myDiagram.commitTransaction("add new member");

    where you would make sure the node data object included all of the properties you need. You can also change the relationship dynamically by calling GraphLinksModel.setGroupKeyForNodeData.

    The membership of Links is computed automatically for you by the diagram based on the membership of the connected Nodes. For example, if the Link.fromNode is a top-level node but the Link.toNode is a member of a group, the link is a top-level link. If the two connected nodes both belong to the same group, the link is a member of that group. If the two connected nodes belong to different groups, the link belongs to the common container group, if there is any. Note that if a link connects a member of a group with the group itself, the link is a member of that group.

    All of the group-member relationships effectively form a tree structure. These properties and methods are useful in navigating these relationships:

    As the membership of a group changes, you may want to update the appearance of the group. You can set the memberAdded and memberRemoved properties to be functions that are called. These functions must not modify any membership relationships -- these function properties just exist to update the appearance of the Group.

    You can control whether certain Nodes are added to a Group by CommandHandler.groupSelection or addMembers or CommandHandler.addTopLevelParts by affecting the result of CommandHandler.isValidMember, which is responsible for deciding whether it is OK to add a Node to a Group or to remove a Node from a Group to be a top-level node. You can override that predicate on CommandHandler, but it is easier to set the memberValidation or CommandHandler.memberValidation functional property.

    For a more general discussion of validation, see Learn page on Validation.

    The area occupied by the subgraph is represented in the group's visual tree by a Placeholder. As the group placeholder grows and shrinks based on the sizes and positions of the member nodes and links, the group will grow and shrink accordingly. The placeholder is always the Part.locationObject, although you may specify any Spot as the Part.locationSpot. A Group need not have a placeholder, but it may have at most one.

    A group has its own layout property that is used to position the member nodes and route the member links.

    The Group class also supports the notion of expanding and collapsing the subgraph, causing the member nodes and links to be shown or hidden. Principally this is a matter of setting isSubGraphExpanded. Changes to this property will result in calls to collapseSubGraph or expandSubGraph, as appropriate.

    If you want to change the appearance of the group you can do so in a function that you assign to the subGraphExpandedChanged property. This function must not modify any member relationships or expand or collapse any groups -- the functional property just exists to update the appearance of the Group.

    For more discussion and examples, see SubGraphs.

    If you want the user to be able to create a Group out of the currently selected Parts using the CommandHandler.groupSelection command, you need to first set the CommandHandler.archetypeGroupData property to a data object with isGroup set to true. If you want the user to be able to ungroup a Group, using the CommandHandler.ungroupSelection command, you need to set ungroupable to true.

    For more discussion and examples, see Groups and Sized Groups.

    Only Groups that are in Diagrams can have member Parts or connections via Links. Templates should not be connected with Links, be labels of Links, be members of Groups, have any member Parts, or have any Adornments.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    actionCancel actionDown actionMove actionUp actualBounds adornments alignment alignmentFocus alignmentFocusName angle avoidable avoidableMargin background category click column columnCount columnSizing columnSpan computesBoundsAfterDrag computesBoundsIncludingLinks computesBoundsIncludingLocation containingGroup containingGroupChanged contextClick contextMenu copyable cursor data defaultAlignment defaultColumnSeparatorDashArray defaultColumnSeparatorStroke defaultColumnSeparatorStrokeWidth defaultRowSeparatorDashArray defaultRowSeparatorStroke defaultRowSeparatorStrokeWidth defaultSeparatorPadding defaultStretch deletable desiredSize diagram doubleClick dragComputation elements enabledChanged fromEndSegmentLength fromLinkable fromLinkableDuplicates fromLinkableSelfNode fromMaxLinks fromShortLength fromSpot graduatedMax graduatedMin graduatedRange graduatedTickBase graduatedTickUnit gridCellSize gridOrigin groupable handlesDragDropForMembers height highlightedChanged isActionable isAnimated isClipping isEnabled isHighlighted isInDocumentBounds isLayoutPositioned isLinkLabel isOpposite isPanelMain isSelected isShadowed isSubGraphExpanded isTopLevel isTreeExpanded isTreeLeaf isTreeRoot itemArray itemCategoryProperty itemIndex itemTemplate itemTemplateMap key labeledLink layer layerChanged layerName layout layoutConditions leftIndex linkConnected linkDisconnected linksConnected linkValidation location locationObject locationObjectName locationSpot margin maxLocation maxSize measuredBounds memberAdded memberParts memberRemoved memberValidation minLocation minSize mouseDragEnter mouseDragLeave mouseDrop mouseEnter mouseHold mouseHover mouseLeave mouseOver movable name opacity padding panel part pickable placeholder port portId ports portSpreading position reshapable resizable resizeAdornmentTemplate resizeCellSize resizeObject resizeObjectName rotatable rotateAdornmentTemplate rotateObject rotateObjectName rotationSpot row rowCount rowSizing rowSpan scale segmentFraction segmentIndex segmentOffset segmentOrientation selectable selectionAdorned selectionAdornmentTemplate selectionChanged selectionObject selectionObjectName shadowBlur shadowColor shadowOffset shadowVisible stretch subGraphExpandedChanged text textEditable toEndSegmentLength toLinkable toLinkableDuplicates toLinkableSelfNode toMaxLinks toolTip topIndex toShortLength toSpot treeExpandedChanged type ungroupable viewboxStretch visible wasSubGraphExpanded wasTreeExpanded width zOrder

    Methods

    add addAdornment addColumnDefinition addMembers addRowColumnDefinition addRowDefinition apply attach bind bindModel bindObject bindTwoWay canAddMembers canCopy canDelete canEdit canGroup canLayout canMove canReshape canResize canRotate canSelect canUngroup clearAdornments collapseSubGraph collapseTree copy copyTemplate elt expandSubGraph expandTree findAdornment findBindingPanel findColumnForLocalX findCommonContainingGroup findCommonTreeParent findExternalLinksConnected findExternalNodesConnected findExternalTreeLinksConnected findItemPanelForData findLinksBetween findLinksConnected findLinksInto findLinksOutOf findLinksTo findMainElement findNodesConnected findNodesInto findNodesOutOf findPort findPredecessorParts findRowForLocalY findSubGraphLevel findSubGraphParts findSuccessorParts findTopLevelPart findTreeChildrenLinks findTreeChildrenNodes findTreeLevel findTreeParentChain findTreeParentLink findTreeParentNode findTreeParts findTreeRoot findVisibleNode getAvoidableRect getColumnDefinition getDocumentAngle getDocumentBounds getDocumentPoint getDocumentScale getLocalPoint getRowDefinition graduatedPointForValue graduatedValueForPoint insertAt invalidateLayout isContainedBy isEnabledObject isInTreeOf isMemberOf isVisibleObject move moveTo rebuildItemElements remove removeAdornment removeAt removeColumnDefinition removeRowDefinition set setProperties theme themeData themeModel themeObject trigger updateAdornments updateTargetBindings build defineBuilder definePanelLayout isBuilderDefined isLayoutDefined make takeBuilderArgument

    Properties

    Constructors

    • Constructs an empty Group with no visual elements and no member parts; typically a Group will have some visual elements surrounding a Placeholder.

      The panel type must be a PanelLayout, such as Panel.Position). The string value such as "Auto" may also be used.

      Usage example:

      // Constructs a Group, sets properties on it,
      // adds a data binding to it,
      // and adds two GraphObjects to the Group:
      const g = new go.Group("Auto", {
      margin: 5,
      background: "red"
      })
      .bind("location", "loc", go.Point.parse)
      .add(
      new go.Shape("RoundedRectangle"),
      new go.TextBlock("Some Text")
      );

      Parameters

      • Optionaltype: string | PanelLayout

        a string or PanelLayout, such as "Horizontal", Panel.Vertical. If not supplied, the default Panel type is "Position".

      • Optionalinit: Partial<Group>

        Optional initialization properties.

      Returns Group

    • Constructs an empty Panel. Default type is Panel.Position.

      Parameters

      • Optionalinit: Partial<Group>

        Optional initialization properties.

      Returns Group

    Accessors

    • get actionCancel(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the ActionTool is cancelled and this GraphObject's isActionable is set to true. This property is infrequently set. By default this property is null.

      This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events, in conjunction with ActionTool, pre-empting the normal tool mechanisms.

      The ActionTool does not conduct any transaction, so if this property has a value, the function will not be called within a transaction.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get actionDown(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute on a mouse-down event when this GraphObject's isActionable is set to true. This property is infrequently set. By default this property is null.

      This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events, in conjunction with ActionTool, pre-empting the normal tool mechanisms.

      The ActionTool does not conduct any transaction, so if this property has a value, the function will not be called within a transaction.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get actionMove(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute on a mouse-move event when this GraphObject's isActionable is set to true. This property is infrequently set. By default this property is null.

      This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events, in conjunction with ActionTool, pre-empting the normal tool mechanisms.

      The ActionTool does not conduct any transaction, so if this property has a value, the function will not be called within a transaction.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get actionUp(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute on a mouse-up event when this GraphObject's isActionable is set to true. This property is infrequently set. By default this property is null.

      This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events, in conjunction with ActionTool, pre-empting the normal tool mechanisms.

      The ActionTool does not conduct any transaction, so if this property has a value, the function will not be called within a transaction. If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get actualBounds(): Rect

      This read-only property returns the bounds of this GraphObject in container coordinates. This means that the actualBounds are in the coordinate space of the GraphObject's Panel, unless this is a Part, in which case they are in the Diagram's coordinate system.

      You must not modify any of the properties of the Rect that is the value of this property.

      If this GraphObject is a Part, then the x and y values of the actualBounds are identical to that Part's position, and the width and height values of the actualBounds represent the rectangular space occupied by the Part in Diagram.documentBounds coordinates.

      If this GraphObject is not a top-level object (not a Part), then the actualBounds x and y values represent that GraphObject's position within its Panel. In a Panel of type Panel.Position this is identical to the GraphObject's position, but in other cases it is dependent on the unique workings of each Panel type. The actualBounds width and height of a GraphObject are the final size after the scale and angle are applied.

      It is possible for a GraphObject (be it an GraphObject or a Panel containing several more GraphObjects) to have no containing Part, in which case these GraphObjects cannot possibly be in a Diagram. These GraphObjects are unlikely to have real-number values for their actualBounds, as they may never have had the chance to be measured and arranged.

      As with all read-only properties, using this property as a binding source is unlikely to be useful.

      Returns Rect

    • get adornments(): Iterator<Adornment>

      This read-only property returns an iterator over all of the Adornments associated with this part. After each call to the iterator's next() method that returns true, the iterator's key will be the category and the iterator's value will be an Adornment.

      Templates should not have any adornments.

      Returns Iterator<Adornment>

    • get alignment(): Spot

      Gets or sets the alignment Spot of this GraphObject used in Panel layouts, to determine where in the area allocated by the panel this object should be placed.

      The default value is Spot.Default, which lets the Panel determine the Spot using Panel.defaultAlignment. If that property is also Spot.Default, then the alignment spot will be different depending on the Panel type.

      The alignmentFocus is often used along with this property to specify where this object should be positioned in a Panel.

      A Spot.Default is equivalent to Spot.Center in Spot, Auto, Horizontal, and Vertical panels. For examples of alignments in different panels, see the Learn page on Panels.

      Returns Spot

    • get alignmentFocus(): Spot

      Gets or sets the spot on this GraphObject to be used as the alignment point in Spot and Fixed Panels. Value must be of the Spot.

      The default value is Spot.Default, which means that the Panel type can decide the effective alignment spot.

      The alignment is often used along with this property to specify where this object should be positioned in a Panel.

      For Panel.Graduated, the alignmentFocus spot determines the spot on a child element to be aligned with some point along the main element.

      When you want a link label Node to be positioned by its location spot rather than by this alignmentFocus spot, you can set this property to Spot.None, only on Nodes.

      For examples of alignments in different panels, see the Learn page on Panels.

      Returns Spot

    • get alignmentFocusName(): string

      For Panels which are elements of Spot Panels: Gets or sets the name of this Panel's element that should be used as the alignment object instead of this Panel.

      This allows Spot Panels to align objects that are nested in the element tree of its own elements.

      Returns string

    • get angle(): number

      Gets or sets the angle transform, in degrees, of this GraphObject. Value must be a number. If the value is not between (0 <= value < 360), it will be normalized to be in that range. Zero is along the positive X-axis (rightwards); 90 is along the positive Y-axis (downwards). Default is 0.

      When set on a Graduated Panel's TextBlock label, this value will be be ignored if segmentOrientation is not Orientation.None, Orientation.Along, or Orientation.Upright. OrientAlong and OrientUpright will use this angle relative to the slope of the main path.

      When set on a Link label, this value will be be ignored if segmentOrientation is not Orientation.None.

      Returns number

    • get avoidable(): boolean

      Gets or sets whether this Node is to be avoided by Links whose Link.routing is Routing.AvoidsNodes.

      The default value is true.

      Returns boolean

    • get avoidableMargin(): MarginLike

      Gets or sets the margin around this Node in which avoidable links will not be routed.

      You may need to increase the fromEndSegmentLength and toEndSegmentLength in order to prevent link routes from turning within the avoidable area around the Node.

      Value must be of type Margin. The default margin is Margin(2,2,2,2)

      Returns MarginLike

    • get background(): BrushLike

      Gets or sets the background Brush of this GraphObject, filling the rectangle of this object's local coordinate space. If the object is rotated, the background will rotate with it.

      The value may be either a Brush object or a string that is a CSS color. The default value is null -- no background is drawn. More information about the syntax of CSS color strings is available at: CSS colors (mozilla.org).

      Returns BrushLike

    • get category(): string

      Gets or sets the category of this part, typically used to distinguish different kinds of nodes or links.

      The initial value is an empty string, which is the default category. Any new value must be a string. This should not be set in templates.

      When building Parts for node data or link data in a model, the Diagram will call Model.getCategoryForNodeData or GraphLinksModel.getCategoryForLinkData to get the category string for the data object. The diagram uses this value to look up a template in Diagram.nodeTemplateMap, Diagram.linkTemplateMap or Diagram.groupTemplateMap. That template is copied to create the actual Part that is added to the diagram. The diagram will set this property to remember the category it used.

      Note that the class of the new Part must be the same as the class of the original Part. For example, a Node cannot be replaced by a simple Part or vice-versa. Nor can a Link be replaced by a subclass of Link or vice-versa.

      To change the category for a Part created for model data, call Model.setCategoryForNodeData or GraphLinksModel.setCategoryForLinkData.

      This property is also used to distinguish Adornments on a Part. In this scenario you create the Adornment, often indirectly by specifying a template, and set this property explicitly. For example, ResizingTool.updateAdornments creates a resizing Adornment from the Part.resizeAdornmentTemplate and sets its category to be "Resizing". Changing the category of an existing Adornment will update any adorned part's association.

      Returns string

    • get click(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the user single-primary-clicks on this object. This typically involves a mouse-down followed by a prompt mouse-up at approximately the same position using the left (primary) mouse button. This property is used by the ClickSelectingTool when the user clicks on a GraphObject. The function is called in addition to the DiagramEvent that is raised with the name "ObjectSingleClicked".

      If this property value is a function, it is called with an InputEvent and this GraphObject. The InputEvent.targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject.panels to get to this object.

      From the second argument, obj, you can get to the Node or Link via the part property. From there you can access the bound data via the Panel.data property. So from an event handler you can get the bound data by obj.part.data.

      By default this property is null.

      Objects in Layers that are Layer.isTemporary do not receive click events. If you do want such objects to respond to clicks, set isActionable to true.

      If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      An example of a click event handler is shown in the Arrowheads sample.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get column(): number

      Gets or sets the column of this GraphObject if it is in a Table Panel. The value must be a small non-negative integer. The default is 0.

      Returns number

    • get columnCount(): number

      For "Table" Panels: This read-only property returns the number of columns. This value is only valid after the Panel has been measured.

      Returns number

    • get columnSpan(): number

      Gets or sets the number of columns spanned by this GraphObject if it is in a Table Panel. The value must be a small positive integer. The default is 1.

      Returns number

    • get computesBoundsAfterDrag(): boolean

      Gets or sets whether the size of the area of the Group's placeholder should remain the same during a DraggingTool move until a drop occurs. Groups within temporary layers (such as new Groups during a drag-copy) are unaffected by this property.

      In other words, when the value is true, re-computing the bounds of the members is suspended until a drop occurs, at which time the border is recomputed, perhaps not including some members that had been dragged out and reparented. The initial value is false.

      Returns boolean

    • Gets or sets whether a placeholder's bounds includes the bounds of member Links. The default value is true. If this is false, only non-Link member Parts are used to compute the Placeholder's bounds in document coordinates.

      Returns boolean

    • get computesBoundsIncludingLocation(): boolean

      Gets or sets whether a placeholder's bounds includes the previous Group.location. The default value is false.

      Returns boolean

    • get containingGroup(): Group | null

      Gets or sets the Group of which this Part or Node is a member. This will be null if this is a top-level part.

      You cannot set this property on a Link; it is set for you automatically based on the group memberships of the connected nodes. You cannot set this property on an Adornment at all.

      A template should not be a member of any group.

      Returns Group | null

    • get containingGroupChanged(): ((thisPart: Part, oldGroup: Group | null, newGroup: Group | null) => void) | null

      Gets or sets the function that is called after this Part has changed which Group it belongs to, if any. It is typically used to modify the appearance of the part. The first argument will be this Part. The second argument will be the old Group, or null if it had been a top-level part. The third argument will be the new Group, or null if it is now a top-level part.

      If the value is a function, that function must not modify the part's containing Group. The containing Group has already been changed -- trying to change it again may produce undefined behavior.

      The initial value is null -- no function is called.

      Returns ((thisPart: Part, oldGroup: Group | null, newGroup: Group | null) => void) | null

    • get contextClick(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the user single-secondary-clicks on this object. This typically involves a mouse-down followed by a prompt mouse-up at approximately the same position using the right (secondary) mouse button. This property is used by the ClickSelectingTool when the user clicks on a GraphObject. The function is called in addition to the DiagramEvent that is raised with the name "ObjectContextClicked".

      If this property value is a function, it is called with an InputEvent and this GraphObject. The InputEvent.targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject.panels to get to this object.

      From the second argument, obj, you can get to the Node or Link via the part property. From there you can access the bound data via the Panel.data property. So from an event handler you can get the bound data by obj.part.data.

      By default this property is null.

      Objects in Layers that are Layer.isTemporary do not receive click events. If you do want such objects to respond to clicks, set isActionable to true.

      If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get contextMenu(): Adornment | HTMLInfo | null

      This Adornment or HTMLInfo is shown upon a context click on this object. The default value is null, which means no context menu is shown.

      Changing this value will not modify or remove any existing menu that is being shown for this object.

      Context menus may also depend on having the same data binding as the adorned Part (i.e. the same value for Panel.data).

      Context menus are not copied by copy, so that context menus may be shared by all instances of a template.

      A typical context menu is implemented as an Adornment with several buttons in it. For example, this context menu is defined in the Dynamic Port sample:

      const nodeMenu =  // context menu for each Node
      go.GraphObject.build("ContextMenu").add(
      go.GraphObject.build("ContextMenuButton",
      { click: (e, obj) => addPort("top") })
      .add(new go.TextBlock("Add top port")),
      go.GraphObject.build("ContextMenuButton",
      { click: (e, obj) => addPort("left") })
      .add(new go.TextBlock("Add left port")),
      go.GraphObject.build("ContextMenuButton",
      { click: (e, obj) => addPort("right") })
      .add(new go.TextBlock("Add right port")),
      go.GraphObject.build("ContextMenuButton",
      { click: (e, obj) => addPort("bottom") })
      .add(new go.TextBlock("Add bottom port"))
      );

      and is used in the node template:

      myDiagram.nodeTemplate =
      new go.Node("Table",
      { . . .
      contextMenu: nodeMenu
      }).add(
      . . .
      );

      Context menus are normally positioned by ContextMenuTool.positionContextMenu. However, if there is a Placeholder in the context menu, the context menu (i.e. an Adornment) will be positioned so that the Placeholder is at the same position as this adorned GraphObject.

      The Basic sample also shows how to make context menu items invisible when the command is disabled.

      Replacing this value will not modify or remove any existing context menu that is being shown for this object.

      Read more about context menus at Context Menus.

      Returns Adornment | HTMLInfo | null

    • get copyable(): boolean

      Gets or sets whether the user may copy this part. The initial value is true.

      Returns boolean

    • get cursor(): string

      Gets or sets the mouse cursor to use when the mouse is over this object with no mouse buttons pressed. The value is the empty string when no particular cursor is specified for this object; the actual cursor is determined by any containing Panel.

      The default value is the empty string, which means the current mouse cursor is determined by the Diagram. Other strings should be valid CSS strings that specify a cursor. This provides some more information about cursor syntax: CSS cursors (mozilla.org).

      Read more about cursors at Diagram.currentCursor

      Returns string

    • get data(): any

      Gets or sets the optional model data to which this panel is data-bound. The data must be a JavaScript Object if this is a Part. The data can be any JavaScript value if this is a Panel created for an item in an Array that was data-bound by the itemArray property. The default value is null.

      Setting it to a new value automatically calls updateTargetBindings in order to assign new values to all of the data-bound GraphObject properties.

      Once you set this property you cannot add, remove, or modify any data bindings on any of the GraphObjects in the visual tree of this Panel, including on this panel itself.

      You should not modify this property on a Part that is created automatically to represent model data, nor on a Panel that is created automatically for a data item in the containing Panel's Panel.itemArray. Call Model.removeNodeData and Model.addNodeData if you want to replace this Part with another one, or call Model.removeArrayItem and Model.insertArrayItem if you want to replace this Panel with another one.

      Although you might not be able to replace this data value if this Part was created automatically by the Diagram, you can still modify that data object's properties. Call the appropriate Model method for changing properties that affect the structure of the diagram. Call Model.set for changing other properties that may be the sources of Bindings on GraphObject properties that are in the visual tree of this panel/part.

      Returns any

    • get defaultAlignment(): Spot

      Gets or sets the default alignment spot of this Panel, used as the alignment for an element when its GraphObject.alignment value is Spot.Default. The default value is Spot.Default, which is interpreted by the Panel in whatever manner seems reasonable, depending on the Panel type.

      Returns Spot

    • get defaultColumnSeparatorDashArray(): number[] | null

      For "Table" Panels: Gets or sets the default dash array for a column's separator. RowColumnDefinition.separatorStrokeWidth can override this default value.

      Must be an array of positive numbers and zeroes, or else null to indicate a solid line.

      For example, the array [5, 10] would create dashes of 5 pixels and spaces of 10 pixels.

      Setting an array with all zeroes will set the value to null.

      Default is null.

      Returns number[] | null

    • get defaultRowSeparatorDashArray(): number[] | null

      For "Table" Panels: Gets or sets the default dash array for a row's separator. RowColumnDefinition.separatorDashArray can override this default value.

      Must be an array of positive numbers and zeroes, or else null to indicate a solid line.

      For example, the array [5, 10] would create dashes of 5 pixels and spaces of 10 pixels.

      Setting an array with all zeroes will set the value to null.

      Default is null.

      Returns number[] | null

    • get deletable(): boolean

      Gets or sets whether the user may delete this part. The initial value is true.

      Returns boolean

    • get desiredSize(): Size

      Gets or sets the desired size of this GraphObject in local coordinates. Value must be of type Size. Default is Size(NaN, NaN). You cannot modify the width or height of the value of this property -- if you want to change the desiredSize you must set this property to a different Size.

      Getting or setting width or height is equivalent to getting or setting the width or height of this property.

      The size does not include any transformation due to scale or angle, nor any pen thickness due to Shape.strokeWidth if this is a Shape. If there is a containing Panel the Panel will determine the actual size. If the desiredSize is greater than the allowed size that the GraphObject's Panel determines, then the GraphObject may be visually clipped. If the desiredSize does not meet the constraints of minSize and maxSize, the GraphObject will be resized to meet them.

      Returns Size

    • get diagram(): Diagram | null

      This read-only property returns the Diagram that this Part is in.

      This will be null if it is not in a Layer.

      Returns Diagram | null

    • get doubleClick(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the user double-primary-clicks on this object. This typically involves a mouse-down/up/down/up in rapid succession at approximately the same position using the left (primary) mouse button. This property is used by the ClickSelectingTool when the user clicks on a GraphObject. The function is called in addition to the DiagramEvent that is raised with the name "ObjectDoubleClicked".

      If this property value is a function, it is called with an InputEvent and this GraphObject. The InputEvent.targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject.panels to get to this object.

      From the second argument, obj, you can get to the Node or Link via the part property. From there you can access the bound data via the Panel.data property. So from an event handler you can get the bound data by obj.part.data.

      By default this property is null.

      Objects in Layers that are Layer.isTemporary do not receive click events. If you do want such objects to respond to clicks, set isActionable to true.

      If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      The Class Hierarchy sample demonstrates the definition of a double-click event handler that opens up a web page with the documentation for that class:

      diagram.nodeTemplate =
      new go.Node(...,
      {
      doubleClick: // here the second argument is this object, which is this Node
      (e, node) => { window.open("../api/symbols/" + node.data.key + ".html"); }
      }).add(
      // elements for Node...
      )

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get dragComputation(): ((thisPart: Part, newLoc: Point, snappedLoc: Point) => Point) | null

      Gets or sets the function used to determine the location that this Part can be dragged to. The first argument is a reference to the Part being dragged, the second argument is a Point describing the proposed location, and the third argument is a snapped location, if one was determined during dragging. It should return a Point that is the proposed new location.

      By default this function is null and the DraggingTool uses the snapped location, if one was determined and if DraggingTool.isGridSnapEnabled is true, or the proposed location (the second argument) if not snapping to a grid.

      In either case the DraggingTool will limit the proposed new location by minLocation and maxLocation.

      The function, if supplied, must not have any side-effects.

      An example that limits moving a Node to the current viewport:

        function stayInViewport(part, pt, gridpt) {
      const diagram = part.diagram;
      if (diagram === null) return pt;
      // compute the area inside the viewport
      const v = diagram.viewportBounds.copy();
      v.subtractMargin(diagram.padding);
      // get the bounds of the part being dragged
      const bnd = part.actualBounds;
      const loc = part.location;
      // now limit the location appropriately
      const l = v.x + (loc.x - bnd.x);
      const r = v.right - (bnd.right - loc.x);
      const t = v.y + (loc.y - bnd.y);
      const b = v.bottom - (bnd.bottom - loc.y);
      if (l <= gridpt.x && gridpt.x <= r && t <= gridpt.y && gridpt.y <= b) return gridpt;
      const p = gridpt.copy();
      if (diagram.toolManager.draggingTool.isGridSnapEnabled) {
      // find a location that is inside V but also keeps the part's bounds within V
      const cw = diagram.grid.gridCellSize.width;
      if (cw > 0) {
      while (p.x > r) p.x -= cw;
      while (p.x < l) p.x += cw;
      }
      const ch = diagram.grid.gridCellSize.height;
      if (ch > 0) {
      while (p.y > b) p.y -= ch;
      while (p.y < t) p.y += ch;
      }
      return p;
      } else {
      p.x = Math.max(l, Math.min(p.x, r));
      p.y = Math.max(t, Math.min(p.y, b));
      return p;
      }
      }

      Note that for this functionality you will also probably want to set Diagram.autoScrollRegion to be a zero margin.

        myDiagram.nodeTemplate =
      new go.Node(. . .,
      { dragComputation: stayInViewport },
      . . .
      )

      Returns ((thisPart: Part, newLoc: Point, snappedLoc: Point) => Point) | null

    • get enabledChanged(): ((thisObj: GraphObject, enabled: boolean) => void) | null

      Gets or sets the function to execute when some containing Panel changes the value of Panel.isEnabled. It is typically used to modify the appearance of the object. This function must not change the value of any panel Panel.isEnabled.

      If this property value is a function, it is called with two arguments, this GraphObject and the new value. By default this property is null -- no function is called.

      Returns ((thisObj: GraphObject, enabled: boolean) => void) | null

    • get fromLinkable(): boolean | null

      Gets or sets whether the user may draw Links from this port. This property is used by LinkingBaseTool.isValidFrom.

      The default value is null, which indicates that the real value is inherited from the parent Panel, or false if there is no containing panel.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node, or unless you are disabling the "linkability" of a particular GraphObject inside a Panel whose fromLinkable has been set or bound to true.

      Returns boolean | null

    • get fromLinkableDuplicates(): boolean

      Gets or sets whether the user may draw duplicate Links from this port. This property is used by LinkingBaseTool.isValidLink. The default value is false.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns boolean

    • get fromLinkableSelfNode(): boolean

      Gets or sets whether the user may draw Links that connect from this port's Node. This property is used by LinkingBaseTool.isValidLink. The default value is false.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns boolean

    • Gets or sets the maximum number of links that may come out of this port. This property is used by LinkingBaseTool.isValidFrom.

      The value must be non-negative. The default value is Infinity.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns number

    • get fromShortLength(): number

      Gets or sets how far the end segment of a link coming from this port stops short of the actual port. Positive values are limited by the fromEndSegmentLength or Link.fromEndSegmentLength. Negative values cause the link to extend into the port. The default value is zero.

      This property is useful when you have a thick link and a pointy arrowhead. Normally the link Shape extends all the way to the end of the arrowhead. If the link Shape is wide, its edges will be seen behind the arrowhead. By setting this property to a small positive value, the link Shape can end within the body of the arrowhead, leaving only the point of the arrowhead visible at the end of the link.

      A negative value for this property can also be useful when you want the link Shape to continue into the port, perhaps because a portion of the port is transparent and you want the link to appear to connect visually with a different point on the node.

      The value of Link.fromShortLength, if not NaN, takes precedence over the value at this port when determining the route of the link.

      For examples of how to use this property, see Link Connection Points.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns number

    • get graduatedMax(): number

      For "Graduated" Panels: Gets or sets the maximum value represented. Must be greater than graduatedMin. The default is 100.

      Returns number

    • get graduatedMin(): number

      For "Graduated" Panels: Gets or sets the minimum value represented. Must be less than graduatedMax. The default is 0.

      Returns number

    • get graduatedRange(): number

      For "Graduated" Panels: This read-only property returns the range of values represented by the Panel.

      For example, a graduatedMin of 25 and graduatedMax of 75 would return 50.

      Returns number

    • get graduatedTickBase(): number

      For "Graduated" Panels: Gets or sets the base value which is marked with a tick. The default is 0.

      Returns number

    • get graduatedTickUnit(): number

      For "Graduated" Panels: Gets or sets the difference between two consecutive values marked by ticks. Must be positive. The default is 10.

      Returns number

    • get gridCellSize(): Size

      For "Grid" Panels: Gets or sets the distance between lines. The units are in local coordinates. The default is 10x10. Any new width or height must be a positive real number.

      Returns Size

    • get gridOrigin(): Point

      For "Grid" Panels: Gets or sets an origin point for the grid cells. The units are in local coordinates. The default is (0,0). Any new value must use real numbers.

      Returns Point

    • get handlesDragDropForMembers(): boolean

      Gets or sets whether drag-and-drop events may be bubbled up to this Group if not handled by member Parts. The default value is false -- each Node or Link that is a member of the Group needs to define its own GraphObject.mouseDragEnter, GraphObject.mouseDragLeave, and GraphObject.mouseDrop event handlers if you want dragging/dropping on a member part to act as if the user were acting on the group.

      This is currently restricted to only call the mouseDragEnter, mouseDragLeave, and mouseDrop event handlers defined on the whole Group, not on any element inside the Group's visual tree.

      Returns boolean

    • get height(): number

      Gets or sets the desired height of this GraphObject in local coordinates. This just gets or sets the height component of the desiredSize. Default is NaN.

      Size can also be constrained by setting minSize and maxSize.

      The height does not include any transformation due to scale or angle, nor any pen thickness due to Shape.strokeWidth if this is a Shape. If there is a containing Panel the Panel will determine the actual size.

      Returns number

    • get highlightedChanged(): ((thisPart: Part) => void) | null

      Gets or sets the function to execute when this isHighlighted changes. It is typically used to modify the appearance of the part. This function must not highlight or unhighlight any parts.

      If this property value is a function, it is called with one argument, this Part that whose isHighlighted value changed. By default this property is null.

      Returns ((thisPart: Part) => void) | null

    • get isAnimated(): boolean

      Gets or sets whether this part may be animated. The initial value is true.

      Returns boolean

    • get isClipping(): boolean

      For Spot Panels: Gets or sets whether this Panel's main element clips instead of fills. This assumes that the main element is a Shape. The main Shape element will not paint its stroke, if it has any, and should have its Shape.strokeWidth set to 0.

      Since 2.2: For Groups: Gets or sets whether this Group's Placeholder clips its member nodes. For compatibility, if the Group is a Spot Panel, it will not clip its members.

      When this property is true, the Spot panel will size itself to be the intersection of the main element bounds and all other elements' bounds, rather than the union of these bounds.

      Returns boolean

    • get isHighlighted(): boolean

      Gets or sets whether this Part is highlighted. The initial value is false.

      Highlighted parts may be shown with a different appearance by changing the brush or visibility of one or more of the GraphObjects within the part. One way of doing that is by using binding. Consider part of the definition of a Node template:

      new go.Shape({
      // ... shape properties
      })
      // Shape.fill is bound to Node.data.color
      .bind("fill", "color")
      // Shape.stroke is red when Node.isHighlighted is true, black otherwise
      .bindObject("stroke", "isHighlighted", h => h ? "red" : "black")

      Returns boolean

    • get isInDocumentBounds(): boolean

      Gets or sets whether this Part is part of the document bounds.

      The initial value is true. A value of false causes Diagram.computeBounds to ignore this part. If the value is false, it is possible that user will not be able to scroll far enough to see this part, if the part's GraphObject.actualBounds are outside of the Diagram.documentBounds.

      Returns boolean

    • get isLayoutPositioned(): boolean

      Gets or sets whether a Layout positions this Node or routes this Link. This property affects the value of canLayout.

      The initial value is true, meaning that this part is laid out by the layout responsible for this Part. If this part is a member of a Group, it is the Group.layout, otherwise it is the Diagram.layout.

      A value of false means that this part is not affected by and does not affect any automatic layout, so the layoutConditions property is ignored. You will need to make sure that it has a real location or GraphObject.position value, or else the Part might not be visible anywhere in the diagram.

      Another way of controlling when layouts are invalidated is by setting Part.layoutConditions or Layout.isInitial or Layout.isOngoing.

      Returns boolean

    • get isLinkLabel(): boolean

      This read-only property is true when this Node is a label node for a Link.

      If this is true, then n.labeledLink will be a Link and n.labeledLink.isLabeledLink will be true.

      Returns boolean

    • get isOpposite(): boolean

      For "Horizontal" and "Vertical" Panels: gets or sets whether this Panel arranges its contents from the typical side (left and top, respectively), or the opposite side (right and bottom, respectively).

      The default value is false.

      Returns boolean

    • get isPanelMain(): boolean

      Gets or sets whether a GraphObject is the "main" object for some types of Panel. Panels that use a "main" object include Panel.Auto, Panel.Spot, and Panel.Link.

      Panels that use a "main" object will use the first object that has this property set to true, or else just the first object, if none have the property set.

      Do not modify this property once this object is an element of a panel.

      Returns boolean

    • get isSelected(): boolean

      Gets or sets whether this Part is selected. The initial value is false.

      Selected parts typically are shown either with an Adornment or with a different appearance by changing the brush or visibility of one or more of the GraphObjects within the part.

      Changing this value does not by itself raise any "ChangingSelection" and "ChangedSelection" DiagramEvents. Tools and the CommandHandler and methods such as Diagram.select do raise those DiagramEvents because they want to surround changes to this property with a single "ChangingSelection" DiagramEvent beforehand and a single "ChangedSelection" afterwards.

      Returns boolean

    • get isShadowed(): boolean

      Gets or sets whether this part will draw shadows. The initial value is false.

      By default, setting this property to true will attempt to draw shadows only on the GraphObjects in this Part that appear to act as background objects, and not on GraphObjects that appear to be in front of other GraphObjects in the Part.

      To finely control shadows, you may need to set GraphObject.shadowVisible on elements of this Part, so that they explicitly do or do not get shadowed accordingly.

      The color of the shadow is determined by shadowColor. The opacity of the shadow color is multiplied by the opacity of the shadowed object's brush. So, for example, if you have a Panel with a GraphObject.background that is "transparent", the shadow that is drawn for the panel will also be transparent.

      The direction of the shadow that is cast is controlled by shadowOffset, and is independent of the Diagram.scale. The sharpness of the shadow is controlled by shadowBlur.

      Returns boolean

    • get isSubGraphExpanded(): boolean

      Gets or sets whether the subgraph contained by this group is expanded. Changing this property's value will call collapseSubGraph or expandSubGraph, and also will call the value of subGraphExpandedChanged if it is a function.

      The initial value is true -- this group's member parts are shown.

      There is an analogous property for expanded/collapsed trees of Nodes and Links: Node.isTreeExpanded.

      Returns boolean

    • get isTopLevel(): boolean

      This read-only property is true when this part is not member of any Group node nor is it a label node for a Link.

      Returns boolean

    • get isTreeExpanded(): boolean

      Gets or sets whether the subtree graph starting at this node is expanded. Changing this property's value will call collapseTree or expandTree, and also will call the value of treeExpandedChanged if it is a function.

      The initial value is true -- "tree-child" nodes, and the links to them, are shown.

      There is an analogous property for expanded/collapsed Groups: Group.isSubGraphExpanded.

      Returns boolean

    • get isTreeLeaf(): boolean

      Gets whether this node has no tree children.

      The initial value is true, meaning that there are no links connected with child nodes in the direction given by Diagram.isTreePathToChildren. This value changes automatically as link connections are added to or removed from this node. Links for which Link.isTreeLink is false are ignored.

      Returns boolean

    • get isTreeRoot(): boolean

      Gets whether this node has no tree parent.

      This calls findTreeParentLink to see if a valid parent link connects with this node. If there is no such link, this node must be a "root" node.

      Returns boolean

      since

      3.0

    • get itemArray(): any[] | null

      Gets or sets a JavaScript Array of values or objects, each of which will be represented by a Panel as elements in this Panel. Replacing this array results all of this panel's child objects being replaced with a copy of the Panel found in itemTemplateMap for each particular item in the Array.

      Because the software does not receive any notifications when an Array is modified, any insertions or removals or replacements of data in the Array will not be noticed unless you call Model.insertArrayItem or Model.removeArrayItem. You may also reset this property to its current value (the modified Array) or call updateTargetBindings, if there is a Binding whose target is this property.

      When binding this property, it is commonplace to set Model.copiesArrays and Model.copiesArrayObjects properties to true, so that when a node is copied, the item Array and its contents are copied, not shared. Or more generally, to customize the model's copying processes, you can supply a custom Model.copyNodeDataFunction and perhaps a GraphLinksModel.copyLinkDataFunction.

      Any JavaScript Object that is in this Array must only appear once in the array and must not appear in any other Panel.itemArrays. Use findItemPanelForData to find the data-bound Panel created for an Object in this panel's item Array.

      Non-Object values in an item Array may appear multiple times. An item Array may be shared by multiple Panels.

      Item Arrays should not be used with Grid Panels or Graduated Panels as they may not have nested Panels.

      Returns any[] | null

    • get itemCategoryProperty(): string | ((a: any) => string)

      Gets or sets the name of the item data property that returns a string describing that data's category, or a function that takes an item data object and returns that string; the default value is the name 'category'. This is used to distinguish between different kinds of items in the itemArray.

      The name must not be null. If the value is an empty string, the category is assumed to be an empty string, the default category name, for all item data objects. You must not change this property when the itemArray already has a value.

      Returns string | ((a: any) => string)

    • get itemIndex(): number

      Gets the index of this Panel's data if it was created to represent an item in its containing Panel's Panel.itemArray. The default value is NaN.

      This is only set internally by code such as rebuildItemElements or Model.insertArrayItem when building or shifting Panel representing items in the Panel whose Panel.itemArray was set or bound to an Array of value.

      This property can be used in data bindings within the item template to produce values that depend on its position in the item Array. For example:

      new go.Panel('Vertical', { // the item Panel
      itemTemplate:
      new go.Panel()
      // set Panel.background to a color based on the Panel.itemIndex
      // bound to this Panel itself, not to the Panel.data item
      .bindObject("background", "itemIndex",
      // using this conversion function
      i => (i%2 === 0) ? "lightgreen" : "lightyellow"
      )
      .add(
      new go.TextBlock() // a trivial item template, just showing some text
      .bind("text", '') // sets TextBlock.text = data.items[itemIndex]
      )
      })
      .bind("itemArray", "items")

      The main element of a Spot or Auto or Link Panel, or the first TableRow or TableColumn element of a Table Panel whose isPanelMain property is true, will not have this property set to a number, because it will not have been created by rebuildItemElements.

      Returns number

    • get itemTemplate(): Panel

      Gets or sets the default Panel template used as the archetype for item data that are in itemArray.

      Setting this property just modifies the itemTemplateMap by replacing the entry named with the empty string. Any new value must be a Panel but not a Part. By default this property is null.

      GraphObject.copy when copying a panel will share the itemTemplateMap between the original panel and the copied panel.

      Returns Panel

    • get itemTemplateMap(): Map<string, Panel> | null

      Gets or sets a go.Map mapping template names to Panels. One of these Panels is copied for each item data that is in the itemArray. Replacing this map will automatically rebuild all of the elements in this Panel.

      By default this property is null. All values in the go.Map must be Panels but not Parts.

      If you modify this go.Map, by replacing a Panel or by adding or removing a map entry, you need to explicitly call rebuildItemElements afterwards.

      GraphObject.copy when copying a panel will share the itemTemplateMap between the original panel and the copied panel.

      Returns Map<string, Panel> | null

    • get key(): Key

      This read-only property returns the Part's Model data key if it is in a Diagram and is backed by Model data. Otherwise this returns undefined.

      Returns Key

    • Gets or sets the Link for which this Node is acting as a smart label. Most nodes do not act as link labels, so this property will be null.

      A template should not be a label node for a link.

      Returns Link | null

    • get layer(): Layer | null

      This read-only property returns the Layer that this Part is in. The value is the Layer that is named with the value of layerName. If you want to change what Layer this Part is in, change the value of layerName to refer to a different Layer.

      This will be null if it has not yet been added to a Diagram, or if it has already been removed from a Diagram.

      Returns Layer | null

    • get layerChanged(): ((thisPart: Part, oldLayer: Layer | null, newLayer: Layer | null) => void) | null

      Gets or sets the function to execute when this part changes layers. It is typically used to modify the appearance of the part. This function must not change the layer of this part by setting layerName.

      If this property value is a function, it is called with three arguments, this Part, the old Layer (may be null), and the new Layer (may be null). By default this property is null -- no function is called.

      Returns ((thisPart: Part, oldLayer: Layer | null, newLayer: Layer | null) => void) | null

    • get layerName(): string

      Gets or sets the layer name for this part. The initial value is an empty string, which is the name of the default layer. The value of this property determines the value of layer.

      If this part is not yet in a Diagram, this value is used by Diagram.add to determine which Layer this part should go in. If no layer can be found with this name, it uses the default layer.

      Changing the value of this property while it is already in a layer causes it to change layers if needed.

      It is moderately commonplace to bind the property depending on the isSelected property in order to make sure selected Parts are in front of non-selected Parts, assuming that the "Foreground" Layer isn't used for other purposes.

      new go.Node(. . ., {
      })
      .bindObject("layerName", "isSelected", sel => sel ? "Foreground" : "")
      . . .

      But note that changing the layer of a Group will not change the layer of any of its Group.memberParts. In order to automatically bring a Group and all of its members forward when selected and then back to the default layer when non selected, in addition to the "isSelected" binding above, one would need to implement a Part.layerChanged event handler to do something like:

      new go.Group(. . ., {
      layerChanged: (grp, oldlay, newlay) => {
      grp.memberParts.each(part => part.layerName = newlay.name);
      },
      . . .
      })
      .bindObject("layerName", "isSelected", sel => sel ? "Foreground" : "")
      . . .

      Returns string

    • get layout(): Layout | null

      Gets or sets the Layout used to position all of the immediate member nodes and links in this group. By default this property is an instance of Layout -- no special layout is used, which just makes sure each member node has a valid location.

      A group layout must not be shared with any Diagram.layout.

      Returns Layout | null

    • get layoutConditions(): LayoutConditions

      Gets or sets flags that control when the Layout that is responsible for this Part is invalidated. The initial value is LayoutConditions.Standard, which causes the layout for this part to be invalidated when the part is added or removed or changes visibility or size.

      Individual layout conditions are provided by LayoutConditions.

      This property is ignored when isLayoutPositioned is false -- no operation on this Part will by itself cause the responsible Layout to be invalidated.

      You can also control when layouts are invalidated is by setting Layout.isInitial or Layout.isOngoing.

      Returns LayoutConditions

    • get leftIndex(): number

      For "Table" Panels: Gets or sets the first column that this Panel displays. The default value is 0.

      Returns number

    • get linkConnected(): ((thisNode: Node, newLink: Link, thisPort: GraphObject) => void) | null

      Gets or sets the function that is called after a Link has been connected with this Node. It is typically used to modify the appearance of the node. The first argument will be this Node. The second argument will be a Link that is now connected with this node. The third argument will be a GraphObject port indicating which port the link was connected with.

      If the value is a function, that function must not modify what this Node is connected with. The Link has already been added -- trying to remove it or another link may produce undefined behavior. However, the other end of the link may not yet have been connected with a node (and might never be), so you cannot depend on looking at what the link connects with.

      The default value is null -- no function is called.

      Returns ((thisNode: Node, newLink: Link, thisPort: GraphObject) => void) | null

    • get linkDisconnected(): ((thisNode: Node, oldLink: Link, thisPort: GraphObject) => void) | null

      Gets or sets the function that is called after a Link has been disconnected from this Node. It is typically used to modify the appearance of the node. The first argument will be this Node. The second argument will be a Link that had been connected with this node. The third argument will be a GraphObject port indicating which port the link had been connected with.

      If the value is a function, that function must not modify what this Node is connected with. The Link has already been removed -- trying to add it or another link may produce undefined behavior. The other end of the link may not yet have been disconnected from a node (and might never be), so you cannot depend on looking at what the link connects with.

      The default value is null -- no function is called.

      Returns ((thisNode: Node, oldLink: Link, thisPort: GraphObject) => void) | null

    • get linksConnected(): Iterator<Link>

      This read-only property returns an iterator over all of the Links that are connected with this node. This includes both links that are coming out of this node as well as links that are going into this node. Setting Link.fromNode or Link.toNode to refer to this Node will add that Link to this collection.

      Use the findLinksConnected, findLinksOutOf, or findLinksInto methods to get different subsets of the links, depending on direction or depending on connecting to a particular port.

      A template should not have any links connected with it.

      Returns Iterator<Link>

    • get linkValidation(): | (
          (
              fromNode: Node | null,
              fromPort: GraphObject | null,
              toNode: Node | null,
              toPort: GraphObject | null,
              link: Link | null,
          ) => boolean
      )
      | null

      Gets or sets a predicate that determines whether or not a Link may be connected with this node. If this is non-null, the predicate is called in addition to the predicate that is LinkingBaseTool.linkValidation on the LinkingTool and RelinkingTool. See LinkingBaseTool.isValidLink for more details.

      The default predicate is null, which is equivalent to simply returning true. The first argument will be the proposed "from" Node (may be null). The second argument will be the proposed "from" GraphObject port (may be null). The third argument will be the proposed "to" Node (may be null). The fourth argument will be the proposed "to" GraphObject port (may be null). The fifth argument may be null when asking about creating a new link, or may be a Link when asking about reconnecting an existing link.

      The function, if supplied, must not have any side-effects.

      Returns
          | (
              (
                  fromNode: Node | null,
                  fromPort: GraphObject | null,
                  toNode: Node | null,
                  toPort: GraphObject | null,
                  link: Link | null,
              ) => boolean
          )
          | null

    • get locationObject(): GraphObject

      This read-only property returns the GraphObject that determines the location of this Part. The value will be in the visual tree of this Part and is usually named with the value of locationObjectName. For Adornments and Groups, the locationObject will be the Placeholder, if it has a visible one.

      Returns GraphObject

    • get locationObjectName(): string

      Gets or sets the name of the GraphObject that provides the location of this Part. This name determines the value of locationObject. The actual location also depends on the locationSpot.

      The initial value is an empty string, meaning the whole Part itself determines the location. If you want to use a particular GraphObject in the visual tree of this Part, set this property to be the GraphObject.name of the element that you want to be the locationObject.

      For Groups and Adornments that have Placeholders, this property is ignored, because the locations of those Groups and Adornments are determined by their Placeholders (if it has a visible one), not by another element in their visual trees.

      Returns string

    • get locationSpot(): Spot

      Gets or sets the location Spot of this Node, the spot on the locationObject that is used in positioning this part in the diagram.

      Value must be of the type Spot. The initial value is Spot.TopLeft. The value must be a specific spot -- i.e. one for which Spot.isSpot is true.

      It is commonplace to set this property to Spot.Center, so that the location has a value corresponding to the point at the center of this Part's locationObject element. But the GraphObject.position of a Part is always at the top-left corner point of the GraphObject.actualBounds.

      Note that the locationSpot for Groups and Adornments that have visible Placeholders will always be relative to the Placeholder, because they determine the location for the Group or Adornment and locationObjectName is ignored in those cases.

      Returns Spot

    • get margin(): MarginLike

      Gets or sets the size of empty area around this GraphObject, as a Margin, in the containing Panel coordinates.

      Negative values are permitted but may cause overlaps with adjacent objects in a Panel. You cannot modify the top or left or right or bottom of the value of this property -- if you want to change the margin you must set this property to a different Margin. Default margin is Margin(0,0,0,0).

      For most uses, increasing a margin will increase the space this GraphObject takes in its containing panel. When an object has a GraphObject.stretch value applied, margins may decrease the size of that object.

      The property setter accepts a number instead of a Margin object: providing a number N will result in using a Margin(N, N, N, N). The property getter will always return a Margin.

      Returns MarginLike

    • get maxLocation(): Point

      Gets or sets the maximum location of this Part to which the user may drag using the DraggingTool.

      Value must be of type Point. The initial value is (Infinity, Infinity), which imposes no position constraint. A X value of NaN causes Diagram.computeMove to use the part's current location's X value as the maximum, and similarly for NaN as the Y value.

      Returns Point

    • get maxSize(): Size

      Gets or sets the maximum size of this GraphObject in container coordinates (either a Panel or the document). Any new value must be of type Size; NaN values are treated as Infinity. If you want no maximum width or height, use NaN or Infinity.

      You cannot modify the width or height of the value of this property -- if you want to change the maxSize you must set this property to a different Size. The default value is Infinity by Infinity. A containing Panel will determine the actual size of this object.

      Returns Size

    • get measuredBounds(): Rect

      This read-only property returns the measuredBounds of the GraphObject in container coordinates (either a Panel or the document). This describes the transformed bounds with margins excluded.

      You must not modify any of the properties of the Rect that is the value of this property.

      As with all read-only properties, using this property as a binding source is unlikely to be useful.

      Returns Rect

    • get memberAdded(): ((thisGroup: Group, newPart: Part) => void) | null

      Gets or sets the function that is called after a member Part has been added to this Group. It is typically used to modify the appearance of the group. The first argument will be this Group. The second argument will be a Part, typically a Node, but may be a simple Part or a Link.

      If the value is a function, that function must not modify any membership relationships. The member Part has already been added -- trying to remove it or adding or removing another member or the Group itself may produce undefined behavior.

      The default value is null -- no function is called.

      Returns ((thisGroup: Group, newPart: Part) => void) | null

    • get memberParts(): Iterator<Part>

      This read-only property returns an iterator over the member Parts of this Group. Setting Part.containingGroup to refer to this Group will add that part to this collection. The Parts can be Nodes, Links, Groups, or simple Parts.

      A template should not have any member parts.

      Returns Iterator<Part>

    • get memberRemoved(): ((thisGroup: Group, oldPart: Part) => void) | null

      Gets or sets the function that is called after a member Part has been removed from this Group. It is typically used to modify the appearance of the group. The first argument will be this Group. The second argument will be a Part, typically a Node, but may be a simple Part or a Link.

      If the value is a function, that function must not modify any membership relationships. The member Part has already been removed -- trying to add it or adding or removing another member or the Group itself may produce undefined behavior.

      The default value is null -- no function is called.

      Returns ((thisGroup: Group, oldPart: Part) => void) | null

    • get memberValidation(): ((thisGroup: Group | null, part: Part) => boolean) | null

      Gets or sets the predicate that determines whether or not a Part may become a member of this group. If this is non-null, the predicate is called in addition to any CommandHandler.memberValidation predicate.

      The default predicate is null, which is equivalent to simply returning true. The first argument will be this Group. The second argument will be a Part, typically a Node, but will not be a Link or an Adornment.

      The function, if supplied, must not have any side-effects.

      Returns ((thisGroup: Group | null, part: Part) => boolean) | null

    • get minLocation(): Point

      Gets or sets the minimum location of this Part to which the user may drag using the DraggingTool.

      Value must be of type Point. The initial value is (-Infinity, -Infinity), which imposes no position constraint. A X value of NaN causes Diagram.computeMove to use the part's current location's X value as the minimum, and similarly for NaN as the Y value.

      Returns Point

    • get minSize(): Size

      Gets or sets the minimum size of this GraphObject in container coordinates (either a Panel or the document). Any new value must be of type Size; NaN values are treated as 0.

      You cannot modify the width or height of the value of this property -- if you want to change the minSize you must set this property to a different Size. The default value is zero by zero. A containing Panel will determine the actual size of this object.

      Returns Size

    • get mouseEnter(): ((e: InputEvent, thisObj: GraphObject, prevObj: GraphObject | null) => void) | null

      Gets or sets the function to execute when the user moves the mouse into this object without holding down any buttons. This property is used by the ToolManager.

      If this property value is a function, it is called with an InputEvent, this GraphObject that the mouse is now in, and any previous GraphObject that the mouse was in. The InputEvent.targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject.panels to get to this object. By default this property is null.

      This function is called with Diagram.skipsUndoManager temporarily set to true, so that any changes to GraphObjects are not recorded in the UndoManager. You do not need to start and commit any transaction in this function. After calling this function the diagram will be updated immediately.

      For example, consider the situation where one wants to display buttons that the user can click whenever the user passes the mouse over a node, and the buttons automatically disappear when the mouse leaves the node. This can be implemented by showing an Adornment holding the buttons.

      const nodeContextMenu =
      new go.Adornment("Spot",
      { background: "transparent" }).add( // to help detect when the mouse leaves the area
      new go.Placeholder(),
      new go.Panel("Vertical",
      { alignment: go.Spot.Right, alignmentFocus: go.Spot.Left }).add(
      go.GraphObject.build("Button")
      .add(new go.TextBlock("Command 1"))
      .set({
      click: (e, obj) => {
      const node = obj.part.adornedPart;
      alert("Command 1 on " + node.data.text);
      node.removeAdornment("ContextMenuOver");
      }
      }),
      go.GraphObject.build("Button")
      .add(new go.TextBlock("Command 2"))
      .set({
      click: (e, obj) => {
      const node = obj.part.adornedPart;
      alert("Command 2 on " + node.data.text);
      node.removeAdornment("ContextMenuOver");
      }
      })
      )
      );

      Then in the definition of the Node we can implement a mouseEnter event handler:

      myDiagram.nodeTemplate =
      new go.Node(...,
      {
      . . .
      mouseEnter: (e, node) => {
      nodeContextMenu.adornedObject = node;
      nodeContextMenu.mouseLeave = (ev, cm) => {
      node.removeAdornment("ContextMenuOver");
      }
      node.addAdornment("ContextMenuOver", nodeContextMenu);
      }
      }).add(
      // Node elements ...
      )

      Note how it automatically defines a mouseLeave event handler too. The context menu Adornment is removed either when the mouse leaves the area of the Adornment or when the user executes a button click event handler.

      Returns ((e: InputEvent, thisObj: GraphObject, prevObj: GraphObject | null) => void) | null

    • get mouseHold(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the user holds the mouse still for a while over this object while holding down a button. This property is used by the ToolManager.

      If this property value is a function, it is called with an InputEvent. By default this property is null.

      If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      You can control how long the user must wait during a drag with a motionless mouse before a "mouse hold" event occurs, by setting ToolManager.holdDelay. For example:

      myDiagram = new go.Diagram("myDiagramDiv",
      { "toolManager.holdDelay": 500 }); // 500 milliseconds

      or:

      myDiagram.toolManager.holdDelay = 500;  // 500 milliseconds
      

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get mouseHover(): ((e: InputEvent, thisObj: GraphObject) => void) | null

      Gets or sets the function to execute when the user holds the mouse still for a while over this object without holding down any buttons. This property is used by the ToolManager.

      If this property value is a function, it is called with an InputEvent. By default this property is null.

      If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram.startTransaction and Diagram.commitTransaction.

      You can control how long the user must wait with a motionless mouse before a "mouse hover" event occurs, by setting ToolManager.hoverDelay. For example:

      myDiagram = new go.Diagram("myDiagramDiv",
      { "toolManager.hoverDelay": 500 }); // 500 milliseconds

      or:

      myDiagram.toolManager.hoverDelay = 500;  // 500 milliseconds
      

      Returns ((e: InputEvent, thisObj: GraphObject) => void) | null

    • get mouseLeave(): ((e: InputEvent, thisObj: GraphObject, nextObj: GraphObject | null) => void) | null

      Gets or sets the function to execute when the user moves the mouse out of this object without holding down any buttons. This property is used by the ToolManager.

      If this property value is a function, it is called with an InputEvent, this GraphObject that the mouse has left, and any next GraphObject that the mouse is now in. The InputEvent.targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject.panels to get to this object. By default this property is null.

      This function is called with Diagram.skipsUndoManager temporarily set to true, so that any changes to GraphObjects are not recorded in the UndoManager. You do not need to start and commit any transaction in this function. After calling this function the diagram will be updated immediately.

      For example, the Flow Chart sample automatically shows and hides the ports as the mouse passes over a node. The node template includes the following settings:

      myDiagram.nodeTemplate =
      new go.Node(...,
      {
      . . .
      // handle mouse enter/leave events to show/hide the ports
      mouseEnter: (e, obj) => showPorts(obj.part, true),
      mouseLeave: (e, obj) => showPorts(obj.part, false)
      . . .
      }).add(
      // Node elements ...
      )

      where the showPorts function is defined to set the visible property of each of the port elements of the node.

      Returns ((e: InputEvent, thisObj: GraphObject, nextObj: GraphObject | null) => void) | null

    • get name(): string

      Gets or sets the name for this object. The default value is the empty string. The name should be unique within a Panel, although if it isn't, it reduces the usefulness of methods such as Panel.findObject.

      You must not modify the name of a GraphObject once it is in the visual tree of a Part.

      This is frequently needed to identify a particular GraphObject in the visual tree of a Part, for example as the value of the Part.locationObjectName or Part.selectionObjectName properties.

      Returns string

    • get opacity(): number

      Gets or sets the multiplicative opacity for this GraphObject and (if a Panel) all elements. The value must be between 0.0 (fully transparent) and 1.0 (no additional transparency).

      Unlike visible, Opacity only affects drawing, it does not cause objects to be resized or remeasured. Opacity settings do not change the shape of the object or exclude it from object-picking (does not change whether any objects are found by the "find..." methods).

      This value is multiplicative with any existing transparency, for instance from Layer.opacity or a GraphObject's opacity higher in the visual tree, or from a Brush or image transparency. The default value is 1.

      Returns number

    • get padding(): MarginLike

      Gets or sets the space between this Panel's border and its content. Unlike GraphObject.margin, padding expands the area inside of the Panel's border. If this Panel's size is unconstrained, this will increase the size of the panel. If this Panel's size is constrained, this will decrease the total area for the Panel elements to arrange themselves.

      Unlike margin, increases in size due to padding are visually covered by the GraphObject.background.

      Padding cannot contain negative numbers. The default value is a Margin of zero.

      Returns MarginLike

    • get panel(): Panel | null

      This read-only property returns the GraphObject's containing Panel, or null if this object is not in a Panel.

      Although Part inherits from this class, a Part will never belong to a Panel, so this property will always be null for every Node or Link.

      This property is not settable. Instead, call Panel.add in order to put a GraphObject in a Panel.

      Returns Panel | null

    • get part(): Part | null

      This read-only property returns the Part containing this object, if any. The Part will be the root GraphObject in this GraphObject's visual tree.

      It is common to refer to the containing Part of a GraphObject in order to refer to the Panel.data to which it is bound.

      This property is not settable. If you want this GraphObject to belong to a Part, you will need to add it to a Part, or else add it to some visual tree structure that is added to a Part using Panel.add.

      Note that for objects such as buttons that are in Adornments such as tooltips or context menus, this property will return that Adornment, not the Node or Link that is adorned.

      If you want to find a Group that contains a Part, use the Part.containingGroup property: someObj.part.containingGroup

      Returns Part | null

    • get pickable(): boolean

      Gets or sets whether or not this GraphObject can be chosen by visual "find" or "hit-test" methods such as Diagram.findObjectAt.

      This object does not get any mouse/touch events if it is not visible or if it is not pickable.

      The default value is true -- mouse events on this object will be noticed. If this value is false and this object is a Panel, not only is this Panel not "hittable", but all of the elements inside the Panel will be ignored.

      Returns boolean

    • get placeholder(): Placeholder | null

      This read-only property returns a Placeholder that this group may contain in its visual tree. The value may be null if there is no Placeholder in the visual tree of this Group.

      There may be at most one Placeholder in a Group. The Placeholder determines the Part.location for the Group, when it is visible, and even when isSubGraphExpanded is false. When there is a Placeholder, the Part.locationObjectName is ignored and the Part.locationObject will be this Placeholder.

      Returns Placeholder | null

    • get port(): GraphObject

      This read-only property returns the primary GraphObject representing a port in this node. If there is a GraphObject whose GraphObject.portId is the empty string, return it. If there is no such element, just return this whole Node.

      Returns GraphObject

    • get portId(): string

      Gets or sets an identifier for an object acting as a port on a Node. The default value is null -- this object is not a port.

      A value that is the empty string is used by convention to mean the primary (and usually only) port of the node.

      If a Node has no named ports, then the Node itself is the sole port.

      Note: the only kind of model that can save port information, i.e. portIds that are not an empty string, for links is a GraphLinksModel whose GraphLinksModel.linkFromPortIdProperty and GraphLinksModel.linkToPortIdProperty have been set to name properties on the link data objects.

      The value should be unique within the Node. You must not modify this property once this GraphObject is in the visual tree of a Node.

      See the Learn page on ports for usage information and examples.

      Returns string

    • get position(): Point

      Gets or sets the position of this GraphObject in container coordinates (either a Panel or the document). Value must be of type Point. You cannot modify the x or y of the value of this property -- if you want to change the position you must set this property to a different Point. Default is Point(NaN, NaN).

      For Parts, see also Part.location.

      Returns Point

    • get reshapable(): boolean

      Gets or sets whether the user may reshape this part. The initial value is false.

      Returns boolean

    • get resizeCellSize(): Size

      Gets or sets the width and height multiples used when resizing. By default this property is the Size(NaN, NaN).

      Returns Size

    • get resizeObjectName(): string

      Gets or sets the name of the GraphObject that should get a resize handle when this part is selected. The value of this property affects the value of resizeObject. The initial value is an empty string, meaning the whole Part itself gets any resize handle.

      Returns string

    • get rotateObjectName(): string

      Gets or sets the name of the GraphObject that should get a rotate handle when this part is selected. The value of this property affects the value of rotateObject. The initial value is an empty string, meaning the whole Part itself gets any rotate handle.

      Returns string

    • get rotationSpot(): Spot

      Gets or sets the spot on the rotateObject that is used in rotating this part with the RotatingTool.

      Value must be of the type Spot. The value must be a specific spot -- i.e. one for which Spot.isSpot is true, or else Spot.Default.

      If the value is Spot.Default, the RotatingTool uses the locationSpot if the rotateObject is equal to the locationObject, otherwise it uses Spot.Center.

      The initial value is Spot.Default.

      Returns Spot

      since

      2.0

    • get row(): number

      Gets or sets the row of this GraphObject if it is in a Table Panel. The value must be a small non-negative integer. The default is 0.

      Returns number

    • get rowCount(): number

      For "Table" Panels: This read-only property returns the number of rows. This value is only valid after the Panel has been measured.

      Returns number

    • get rowSpan(): number

      Gets or sets the number of rows spanned by this GraphObject if it is in a Table Panel. The value must be a small positive integer. The default is 1.

      Returns number

    • get scale(): number

      Gets or sets the scale transform of this GraphObject. Value must be a number; larger values will make this object appear bigger. Default is 1.

      Returns number

    • get segmentFraction(): number

      Gets or sets the fractional distance along a segment of a GraphObject that is in a Link. The value should be between zero and one, where zero is at the point at the start of the segment, and where one is at the point at the end of the segment. The default value is zero.

      If segmentIndex is set to NaN, the fractional distance will be calculated along the entire link route.

      For examples of how to use this property, see Link Labels.

      Returns number

    • get segmentIndex(): number

      Gets or sets the segment index of a GraphObject that is in a Link. Non-negative numbers count up from zero, which is the first segment, at the "from" end of the Link. Negative numbers count segments from the "to" end of the Link, where -1 means the last segment and -2 means the next-to-last segment. The default value is -Infinity. The value should be an integer or NaN.

      Setting this value to NaN means segmentFraction's fractional distance will be calculated along the entire link route. A NaN value also means the Link.midPoint and Link.midAngle will not be used when determining label positions.

      If you do not set this property, the Link will choose a place that is approximately at the mid-point of the link's route.

      For examples of how to use this property, see Link Labels.

      Returns number

    • get segmentOffset(): Point

      Gets or sets the offset of a GraphObject that is in a Link from a point on a segment or in a Panel.Graduated from a point along the main element. The X component of the Point indicates the distance along the route, with positive values going further toward the "to" end of the link or panel. The Y component of the Point indicates the distance away from the route, with positive values towards the right as seen when facing further towards the "to" end of the link or panel. The value defaults to the Point (0, 0). You cannot modify the x or y of the value of this property -- if you want to change the segmentOffset you must set this property to a different Point.

      For labels that are near either end of a link, it may be convenient to set the segmentOffset to Point(NaN, NaN). This causes the offset to be half the width and half the height of the label object.

      For examples of how to use this property, see Link Labels.

      Returns Point

    • get segmentOrientation(): Orientation

      Gets or sets the orientation of a GraphObject that is in a Link or Panel.Graduated. This controls the automatic rotation of the object by the Link Panel or Graduated Panel. The only accepted values are the Link "Orient..." values of Link and the default value: Orientation.None.

      When the value is Orientation.None, the angle of this object is unchanged as the link is routed. Setting this to a value of Orientation.Along will cause routing to set the angle to be the angle of the segment that this object is on. Other values compute the angle somewhat differently. If the value is changed back to Orientation.None, the angle of this object is set to zero.

      Note that when this property is not Orientation.None, this property takes precedence over any setting or binding of the angle property. Changes to the angle caused by orientation might not result in Changed events, and any original value for the angle may be lost.

      In the case of Graduated Panels, if this value is Orientation.None, Orientation.Along, or Orientation.Upright, any TextBlock label angle will be respected. Depending on this value, the effective TextBlock angle will be either fixed or relative to the slope of the path where it is rendered.

      For examples of how to use this property, see Link Labels.

      Returns Orientation

    • get selectionAdorned(): boolean

      Gets or sets whether a selection adornment is shown for this part when it is selected. The initial value is true.

      Returns boolean

    • get selectionChanged(): ((thisPart: Part) => void) | null

      Gets or sets the function to execute when this part is selected or deselected. It is typically used to modify the appearance of the part. This function must not select or deselect any parts.

      If this property value is a function, it is called with one argument, this Part that was selected or that became unselected. When it is called, the value of Diagram.skipsUndoManager is temporarily set to true. By default this property is null.

      This function is called with Diagram.skipsUndoManager temporarily set to true, so that any changes to GraphObjects are not recorded in the UndoManager. You do not need to start and commit any transaction in this function.

      Returns ((thisPart: Part) => void) | null

    • get selectionObjectName(): string

      Gets or sets the name of the GraphObject that should get a selection handle when this part is selected. The value of this property affects the value of selectionObject. The initial value is an empty string, meaning the whole Part itself gets any selection handle.

      If no GraphObject has a GraphObject.name that is this name, selectionObject returns the whole Part.

      Returns string

    • get shadowBlur(): number

      Gets or sets the numerical value that describes the shadow's blur. Number must be non-negative and non-infinity. A value of 0 would mean the shadow does not blur and larger numbers represent increasingly more blur. The total blur area is independent of the Part's area and can become quite large as this number is increased.

      This value is not affected by scale. Default value is 4.

      Returns number

    • get shadowColor(): string

      Gets or sets the CSS string that describes a shadow color. Default is 'gray'. Brushes cannot be used for this property -- only strings.

      The opacity of the shadow color is multiplied by the opacity of the shadowed object's brush. So, for example, if you have a Panel with a GraphObject.background that is "transparent", the shadow that is drawn for the panel will also be transparent.

      Returns string

    • get shadowVisible(): boolean | null

      Gets or sets whether or not this GraphObject will be shadowed inside a Part that has Part.isShadowed set to true.

      The default is null, which means this GraphObject will obey the default shadow rules (see Part.isShadowed).

      A value of true or false will ensure that this part is shadowed or not regardless of the default shadow rules, but this GraphObject's shadowed status will not affect other GraphObjects in the Part.

      Typically this property does not need to be set, but you may need to set this value to false on GraphObjects inside a Part that you do not wish to be shadowed.

      Returns boolean | null

    • get stretch(): Stretch

      Gets or sets the stretch of the GraphObject. This controls whether the width and/or height of this object automatically adjusts to fill the area allotted by the containing Panel.

      The only accepted values are listed as constant properties of GraphObject, such as Stretch.None, Stretch.Fill, Stretch.Horizontal, or Stretch.Vertical. The default value is Stretch.Default, which allows the Panel to decide how to treat this object, depending on the type of Panel.

      Objects with an angle that are stretched may look incorrect unless the angle is a multiple of 90.

      Stretch will have have different effects based upon the Panel containing this object. Elements of:

      • Auto panels will not stretch, except the main element growing to fill the panel or being made uniform
      • Horizontal panels will only stretch vertically
      • Vertical panels will only stretch horizontally
      • Spot panels will stretch to the size of the main element
      • Table panels will stretch to the size of their cell, defined by their row and column, which is usually determined by other GraphObjects in that cell that are not stretching
      • Grid panels, Link panels, and Graduated panels will not stretch

      Returns Stretch

    • get subGraphExpandedChanged(): ((thisGroup: Group) => void) | null

      Gets or sets the function that is called when isSubGraphExpanded has changed value. The argument to that function will be this Group.

      If the value is a function, that function must not expand or collapse any groups. The Group has already been expanded or collapsed -- trying to change it again may produce undefined behavior.

      The default value is null -- no function is called.

      Returns ((thisGroup: Group) => void) | null

    • get text(): string

      Gets or sets a text string that is associated with this part.

      The initial value is an empty string. This value is often used for sorting.

      Returns string

    • get textEditable(): boolean

      Gets or sets whether the user may do in-place text editing on TextBlocks in this part that have TextBlock.editable set to true. The initial value is true.

      Returns boolean

    • get toLinkable(): boolean | null

      Gets or sets whether the user may draw Links to this port. This property is used by LinkingBaseTool.isValidTo.

      The default value is null, which indicates that the real value is inherited from the parent Panel, or false if there is no containing panel.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node, or unless you are disabling the "linkability" of a particular GraphObject inside a Panel whose toLinkable has been set or bound to true.

      Returns boolean | null

    • get toLinkableDuplicates(): boolean

      Gets or sets whether the user may draw duplicate Links to this port. This property is used by LinkingBaseTool.isValidLink. The default value is false.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns boolean

    • get toLinkableSelfNode(): boolean

      Gets or sets whether the user may draw Links that connect to this port's Node. This property is used by LinkingBaseTool.isValidLink. The default value is false.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns boolean

    • Gets or sets the maximum number of links that may go into this port. This property is used by LinkingBaseTool.isValidTo.

      The value must be non-negative. The default value is Infinity.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns number

    • get toolTip(): Adornment | HTMLInfo | null

      This Adornment or HTMLInfo is shown when the mouse hovers over this object. The default value is null, which means no tooltip is shown.

      A typical tooltip is defined in the following manner, as taken from the Kitten Monitor sample:

      myDiagram.nodeTemplate =
      new go.Node(...,
      { // this tooltip shows the name and picture of the kitten
      toolTip:
      go.GraphObject.build("ToolTip").add(
      new go.Panel("Vertical").add(
      new go.Picture()
      .bind("source", "src", s => return "images/" + s + ".png"),
      new go.TextBlock({ margin: 3 })
      .bind("text", "key")
      )
      )
      }).add(
      // Node elements ...
      )

      Note that this Adornment depends on having the same data binding as the adorned Part (i.e. the same value for Panel.data).

      Tooltips are not copied by copy, so that tooltips may be shared by all instances of a template.

      Tooltips are shown after a timed delay given by the ToolManager.hoverDelay. You can change the delay time by:

      myDiagram = new go.Diagram("myDiagramDiv",
      { "toolManager.hoverDelay": 500 }); // 500 milliseconds

      or:

      myDiagram.toolManager.hoverDelay = 500;  // 500 milliseconds
      

      Tooltips are normally positioned by ToolManager.positionToolTip. However, if there is a Placeholder in the tooltip, the tooltip (i.e. an Adornment) will be positioned so that the Placeholder is at the same position as this adorned GraphObject.

      Replacing this value will not modify or remove any existing tooltip that is being shown for this object.

      Read more about tooltips at ToolTips.

      Returns Adornment | HTMLInfo | null

    • get topIndex(): number

      For "Table" Panels: Gets or sets the first row that this Panel displays. The default value is 0.

      Returns number

    • get toShortLength(): number

      Gets or sets how far the end segment of a link going to this port stops short of the actual port. Positive values are limited by the toEndSegmentLength or Link.toEndSegmentLength. Negative values cause the link to extend into the port. The default value is zero.

      This property is useful when you have a thick link and a pointy arrowhead. Normally the link Shape extends all the way to the end of the arrowhead. If the link Shape is wide, its edges will be seen behind the arrowhead. By setting this property to a small positive value, the link Shape can end within the body of the arrowhead, leaving only the point of the arrowhead visible at the end of the link.

      A negative value for this property can also be useful when you want the link Shape to continue into the port, perhaps because a portion of the port is transparent and you want the link to appear to connect visually with a different point on the node.

      The value of Link.toShortLength, if not NaN, takes precedence over the value at this port when determining the route of the link.

      For examples of how to use this property, see Link Connection Points.

      You must set this property on a GraphObject whose portId is non-null, unless the whole Node is acting as a single port, in which case this property should be set on the Node.

      Returns number

    • get treeExpandedChanged(): ((thisNode: Node) => void) | null

      Gets or sets the function that is called when isTreeExpanded has changed value. The argument to that function will be this Node.

      If the value is a function, that function must not expand or collapse any trees of nodes and links. The Node has already been expanded or collapsed -- trying to change it again may produce undefined behavior.

      The default value is null -- no function is called.

      Returns ((thisNode: Node) => void) | null

    • get ungroupable(): boolean

      Gets or sets whether the user may ungroup this group. The initial value is false.

      Returns boolean

    • get visible(): boolean

      Gets or sets whether a GraphObject is visible. The default value is true. A not visible object takes no space in the Panel that it is in. Toggling visibility may cause elements in the visual tree to re-measure and re-arrange. Making a Panel not visible causes all of its elements not to be seen or receive input events. Changing a Panel to become visible causes all of its elements to be seen and be active, unless those elements are themselves not visible.

      This object does not get any mouse/touch events if it is not visible or if it is not pickable.

      One can have a visible Shape that is not drawn by setting its Shape.fill and Shape.stroke to null or to "transparent". Similarly, one can set TextBlock.stroke to null or to "transparent". It is also possible make a GraphObjects transparent by setting GraphObject.opacity to 0. Finally, one can make a whole Layer-full of Parts invisible by setting Layer.visible to false.

      Use the isVisibleObject predicate to see if this GraphObject is visible and is inside a Panel that is isVisibleObject, and so forth up the chain of panels until reaching the Part.

      For Parts, you can call the Part.isVisible predicate to determine if not only the Part is visible but also any containing Group or Link, and whether the Layer it is in is visible.

      Returns boolean

    • get wasSubGraphExpanded(): boolean

      Gets or sets whether the subgraph starting at this group had been collapsed by a call to expandSubGraph on the containing Group. The initial value is false.

      Returns boolean

    • get wasTreeExpanded(): boolean

      Gets or sets whether the subtree graph starting at this node had been collapsed by a call to expandTree on the parent node. The initial value is false.

      Returns boolean

    • get width(): number

      Gets or sets the desired width of this GraphObject in local coordinates. This just gets or sets the width component of the desiredSize. Default is NaN.

      Size can also be constrained by setting minSize and maxSize.

      The width does not include any transformation due to scale or angle, nor any pen thickness due to Shape.strokeWidth if this is a Shape. If there is a containing Panel the Panel will determine the actual size.

      Returns number

    • get zOrder(): number

      Gets or sets the Z-ordering position of this Part within its Layer.

      Within the same layer, nodes with larger zOrder values are placed in front of nodes with smaller zOrder values. When the value is NaN the ordering is not specified. The default value is NaN.

      When a Group has a zOrder value of NaN, it is automatically placed behind its member nodes and links that also have no zOrder. Such automatic ordering is not guaranteed if any nodes including the groups have a numeric zOrder. If you do want to specify the zOrder of nodes, you should also specify the zOrder of their containing groups unless those groups are in different layers.

      Returns number

    Methods

    • Adds a number of GraphObjects to the end of this Panel's list of elements, visually in front of all of the other elements.

      If the element to be added is already in this Panel's list of elements, the object is moved to the end of the list. You cannot add a GraphObject to a Panel if that GraphObject is already in a different Panel.

      Parameters

      Returns this

      this Panel

    • Associate an Adornment with this Part, perhaps replacing any existing adornment of the same category. Don't forget to set Adornment.adornedObject before calling this method. This adds the Adornment to the Layer named by layerName, normally "Adornment".

      Adornments are also data bound to the same data that this Part has, if any. If the Adornment was already associated with a Part, it is unassociated with that old Part.

      This method should not be called on templates.

      Parameters

      • category: string

        a string identifying the kind or role of the given adornment for this Part.

      • ad: Adornment | null

        the new Adornment.

      Returns void

    • For "Table" Panels: Sets the column RowColumnDefinition given by the index. If the column definition does not exist on the Panel, this will create it. If it already exists on the Panel, this will copy the properties of the given RowColumnDefinition options onto that definition.

      This is a convenience method for addRowColumnDefinition. Instead of writing:

      .addRowColumnDefinition(new go.RowColumnDefinition({ column: 2, width: 60 }))
      

      You can write:

      .addColumnDefinition(2, { width: 60 })
      

      Parameters

      • colIndex: number

        the non-negative zero-based integer column index.

      • options: Partial<RowColumnDefinition>

        the initialization options passed to the RowColumnDefinition constructor.

      Returns this

      this Panel

    • For "Table" Panels: Sets the row RowColumnDefinition given by the index. If the row definition does not exist on the Panel, this will create it. If it already exists on the Panel, this will copy the properties of the given RowColumnDefinition options onto that definition.

      This is a convenience method for addRowColumnDefinition. Instead of writing:

      .addRowColumnDefinition(new go.RowColumnDefinition({ row: 2, height: 60 }))
      

      You can write:

      .addRowDefinition(2, { height: 60 })
      

      Parameters

      • rowIndex: number

        the non-negative zero-based integer row index.

      • options: Partial<RowColumnDefinition>

        the initialization options passed to the RowColumnDefinition constructor.

      Returns this

      this Panel

    • This method takes a function that can be used to apply multiple settings, bindings, or Panel.add calls, to different GraphObjects. This is common in initialization. If you are just adding settings, bindings, or GraphObjects to a single GraphObject, you do not need to use this, you can just chain calls to set, bind, and Panel.add instead. This method is mostly useful when setting the same values across multiple GraphObjects or in multiple templates.

      For example:

      // This can be used by several node templates
      // to set multiple properties and bindings on each
      function nodeStyle(node) {
      node
      .set({ background: 'red' })
      .bind("location")
      .bind("desiredSize", "size", go.Size.parse)
      }

      // ... in a Node template:
      new go.Node("Auto")
      .apply(nodeStyle)
      .add(
      new go.Shape(. . .),
      new go.Panel(. . .)
      )
      // ...rest of Node template

      // ... in another Node template:
      new go.Node("Vertical", { padding: 5 })
      .apply(nodeStyle)
      // ...rest of Node template

      In version 3.1 we have added the ability to pass arguments to the function. For example:

      function shapeStyle(shp, fig, fill) {  // FIG and FILL are optional
      shp.width = 32;
      shp.height = 32;
      shp.figure = fig ? fig : 'Diamond';
      shp.fill = fill ? fill : 'gray';
      shp.strokeWidth = 0;
      }

      // ... in a template:
      new go.Node(. . .) . . .
      .add(
      . . .
      new go.Shape(. . .).apply(shapeStyle),
      new go.Shape(. . .).apply(shapeStyle, 'Triangle'),
      new go.Shape(. . .).apply(shapeStyle, 'Circle', 'red'),
      . . .
      )

      Parameters

      • func: (thisObject: this, ...args: any[]) => void

        a function that takes this GraphObject

      • ...args: any[]

      Returns this

      this GraphObject

      since

      2.2

      see

      set a type-safe method to set a collection of properties

    • This method sets a collection of properties according to the property/value pairs on the given Object, or array of Objects, in the same manner as GraphObject.make does when constructing a GraphObject.

      This method is used in initialization, but typically you should use set instead, unless you need to attach new properties that do not exist on the GraphObject, or to set sub-properties. New property names must start with an underscore "_" character.

      Calling this method is much less efficient than setting properties directly, and does not do compile-time type checking.

      new go.Shape()
      .bind("fill", "color")
      .bind("strokeWidth", "width")
      .attach({ // use .attach for untyped property attachments
      "_color": "Red"
      })

      Parameters

      • config: any

        a JavaScript object containing properties to attach, or an array of such objects.

      Returns this

      this GraphObject

      since

      2.2

      see
      • setProperties a synonym of this method
      • set a type-safe method to set a collection of properties
    • Add a data-binding to this GraphObject for the given property names and optional conversion functions. The added Binding will be of kind Binding.isToData.

      Do not add, modify, or remove any Bindings after this GraphObject has been copied.

      An example using .bind with the shorthand arguments:

      myDiagram.nodeTemplate =
      new go.Node("Horizontal")
      // a OneWay Binding, from data.loc to Node.location
      .bind("location", "loc", go.Point.parse)
      // ... rest of the Node template

      To get a TwoWay Binding call Binding.makeTwoWay instead.

      myDiagram.nodeTemplate =
      new go.Node("Horizontal")
      // this is now a TwoWay Binding:
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify)
      // ... rest of the Node template

      Read more about Bindings at the Learn page about Data Bindings.

      Parameters

      • targetprop: string

        A string naming the target property on this GraphObject. This should not be the empty string. This becomes the value of Binding.targetProperty.

      • Optionalsourceprop: string

        A string naming the source property on the bound data object. If this is the empty string, the whole Panel.data object is used. If this argument is not supplied, the source property is assumed to be the same as the target property. This becomes the value of Binding.sourceProperty.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. This becomes the value of Binding.converter.

      • Optionalbackconv: BackConversion

        Deprecated: call bindTwoWay instead.

      Returns this

      this GraphObject

      since

      2.2

    • Add a data-binding of a property on this GraphObject to a property on a binding source object.

      Do not add, modify, or remove any Bindings after this GraphObject has been copied.

      An example using .bind with the Binding argument:

      myDiagram.nodeTemplate =
      new go.Part("Horizontal")
      .bind(new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify))
      // ...

      However, one could achieve the same effect by using a different method:

      myDiagram.nodeTemplate =
      new go.Part("Horizontal")
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify)
      // ...

      Read more about Bindings at the Learn page about Data Bindings.

      Parameters

      Returns this

      this GraphObject

    • Add a data-binding from the shared Model.modelData object to a property on this GraphObject. We recommend that you not use TwoWay binding for this kind of Binding.isToModel binding.

      This is a convenience function for bind that additionally calls Binding.ofModel on the created binding. See the documentation for bind for details.

      The use of TwoWay model data bindings is very uncommon. Note that in order to get a TwoWay Binding one must pass a value for the fourth argument to this method. Pass null when you do not want a back-conversion function applied when passing a property value from this target GraphObject to the source data object.

      Read more about Bindings at the Learn page about Data Bindings.

      Parameters

      • targetprop: string | Binding

        A string naming the target property on this GraphObject. This should not be the empty string. This becomes the value of Binding.targetProperty.

      • Optionalsourceprop: string

        A string naming the source property on the bound shared data object. If this is the empty string, the whole Panel.data object is used. If this argument is not supplied, the source property is assumed to be the same as the target property. This becomes the value of Binding.sourceProperty.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. This becomes the value of Binding.converter.

      • Optionalbackconv: BackConversion

        An optional conversion function to convert GraphObject property values back to data values. Note that for TwoWay bindings whenever the target property is modified, the shared data object will be updated. Specifying this modifies the binding to set its Binding.mode to be BindingMode.TwoWay. Passing null produces a TwoWay Binding, but no back-conversion function will be called. Pass undefined, or do not provide an argument here, in order to produce the normal OneWay binding. This becomes the value of Binding.backConverter.

      Returns this

      this GraphObject

      since

      3.0

    • Add a data-binding from a GraphObject property in this GraphObject's binding Panel to a property on this GraphObject. We recommend that you use this kind of Binding.isToObject binding sparingly.

      This is a convenience function for bind that additionally calls Binding.ofObject on the created binding. It passes the param objectSrcname to the Binding.ofObject call. See the documentation for bind for details.

      The use of TwoWay GraphObject bindings is uncommon. Note that in order to get a TwoWay Binding one must pass a value for the fourth argument to this method. Pass null when you do not want a back-conversion function applied when passing a property value from this target GraphObject to the source object.

      Read more about Bindings at the Learn page about Data Bindings.

      Parameters

      • targetprop: string | Binding

        A string naming the target property on this target GraphObject. This should not be the empty string. This becomes the value of Binding.targetProperty.

      • Optionalsourceprop: string

        A string naming the source property on the source GraphObject. If this is the empty string, the result of GraphObject.findBindingPanel is used. If this argument is not supplied, the source property is assumed to be the same as the target property. This becomes the value of Binding.sourceProperty.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. This becomes the value of Binding.converter.

      • Optionalbackconv: BackConversion

        An optional conversion function to convert GraphObject property values back to property values. Passing a not-undefined value modifies the binding to set its Binding.mode to be BindingMode.TwoWay. Pass null if you want the binding to be TwoWay but not to invoke any back-conversion function. Pass undefined, or do not provide an argument in this position, for the normal OneWay binding. This becomes the value of Binding.backConverter.

      • OptionalobjectSrcname: string

        An optional GraphObject.name used to identify the source GraphObject by calling Panel.findObject. If the value is an empty string or is not supplied, the source binding Panel is used -- the Part or the item Panel. This becomes the value of Binding.sourceName.

      Returns this

      this GraphObject

      since

      3.0

    • This convenience function works like GraphObject.bind, creating a Binding, then also calls Binding.makeTwoWay on it. These are equivalent:

      .bind("text", "text", null, null)
      .bindTwoWay("text")

      As are these:

      .bind("text", "someProp", null, null)
      .bindTwoWay("text", "someProp")

      The first creates a two-way binding because specifying anything for the 4th argument (BackConversion) automatically sets the Binding.mode to be BindingMode.TwoWay. However, it requires specifying the middle arguments, which may not be necessary.

      Read more about Bindings at the Learn page about Data Bindings.

      Parameters

      • targetprop: string | Binding

        A string naming the target property on this GraphObject. This should not be the empty string. This becomes the value of Binding.targetProperty.

      • Optionalsourceprop: string

        A string naming the source property on the bound data object. If this is the empty string, the whole Panel.data object is used. If this argument is not supplied, the source property is assumed to be the same as the target property. This becomes the value of Binding.sourceProperty.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. This becomes the value of Binding.converter.

      • Optionalbackconv: BackConversion

        An optional conversion function to convert GraphObject property values back to data values. Specifying this modifies the binding to set its Binding.mode to be BindingMode.TwoWay. Pass null or undefined in order for no back-conversion function to be called. This becomes the value of Binding.backConverter.

      Returns this

      this GraphObject

      since

      3.0

    • This predicate is called by Layout implementations to decide whether this Part should be positioned and might affect the positioning of other Parts.

      This is false if isLayoutPositioned is false, if isVisible returns false, or if the part is in a temporary Layer.

      This does not check Diagram.isReadOnly or Model.isReadOnly, but commands and tools should check those properties.

      Returns boolean

    • Remove all adornments associated with this part.

      Returns void

    • Hide each of the member nodes and links of this group, and recursively collapse any member groups. This changes the value of Part.isVisible of the whole subgraph and the parts owned by those member nodes and links. However, this group's visibility is unchanged.

      This sets isSubGraphExpanded to false on this group and on all of the nested Groups. For those nested Groups that were expanded, wasSubGraphExpanded is set to true.

      This method does not perform a transaction or start any animation.

      To collapse trees made of Nodes and Links, use Node.collapseTree.

      Returns void

    • Hide each child node and the connecting link, and recursively collapse each child node. This changes the value of Part.isVisible of the whole subtree and the parts owned by those nodes and links. However, this root node's visibility is unchanged.

      Links are assumed to go from the parent node to the children nodes, unless Diagram.isTreePathToChildren is false. Links for which Link.isTreeLink is false are ignored.

      This sets isTreeExpanded to false on this node and on all of the children nodes. For those child nodes that were expanded when they were collapsed, wasTreeExpanded is set to true.

      You can also pass in a number of levels to hide nodes beyond a certain level starting at this node. If you want to make sure that all nodes are expanded up to a particular level, call expandTree. If you want to do both, call expandTree before calling collapseTree to collapse nodes expanded due to the wasTreeExpanded flag.

      This method does not perform a transaction or start any animation. You may want to call the CommandHandler.collapseTree command, which does perform a transaction and raise a DiagramEvent.

      To collapse a Group's subgraph of Nodes and Links, use Group.collapseSubGraph.

      Parameters

      • Optionallevel: number

        How many levels of the tree, starting at this node, to keep expanded if already expanded; the default is 1, hiding all tree children of this node. Values less than 1 are treated as 1.

      Returns void

    • Creates a deep copy of this Panel and returns it.

      Returns this

    • Make a deep copy of this Panel and allow it to be used as a template. This makes copies of Bindings, unlike the regular copy() method. Pass true as the argument in order to freeze the Bindings, allowing it to operate efficiently as a template. A false value (which is the default) allows further additions/modifications of the bindings in the copied Panel.

      Parameters

      • Optionalfreeze: boolean

        whether to freeze the Bindings in the copy; default is false

      Returns this

      since

      2.2

    • Returns the GraphObject in this Panel's list of elements at the specified index.

      Parameters

      • idx: number

      Returns GraphObject

    • Show each member node and link, and perhaps recursively expand nested subgraphs. This may change the value of Part.isVisible of the whole subgraph and the parts owned by those member nodes and links. However, this group's visibility is unchanged.

      This sets isSubGraphExpanded to true on this group and on all of the nested Groups. This will expand a nested group only if its wasSubGraphExpanded property was true.

      This method does not perform a transaction or start any animation.

      To expand trees made of Nodes and Links, use Node.expandTree.

      Returns void

    • Show each child node and the connecting link, and perhaps recursively expand their child nodes. This may change the value of Part.isVisible of the whole subtree and the parts owned by those nodes and links. However, this root node's visibility is unchanged.

      This sets isTreeExpanded to true on this node and on all of the children nodes. Links are assumed to go from the parent node to the children nodes, unless Diagram.isTreePathToChildren is false. Links for which Link.isTreeLink is false are ignored.

      This will expand a tree child node only if its wasTreeExpanded property was true.

      You can also pass in a number of levels in order to be sure that all nodes starting at this node and up through that number of levels are visible. If you want to make sure that there are no nodes expanded after a particular level, call collapseTree. If you want to do both, call expandTree before calling collapseTree to collapse nodes expanded due to the wasTreeExpanded flag.

      This method does not perform a transaction or start any animation. You may want to call the CommandHandler.expandTree command, which does perform a transaction and raise a DiagramEvent.

      To expand a Group's subgraph of Nodes and Links, use Group.expandSubGraph.

      Parameters

      • Optionallevel: number

        How many levels of the tree should be expanded; the default is 2, showing all tree children of this node and potentially more. Values less than 2 are treated as 2.

      Returns void

    • Find an Adornment of a given category associated with this Part.

      Templates should not have any adornments.

      Parameters

      • category: string

      Returns Adornment | null

      Returns null if no such Adornment was found.

    • Walks up the visual tree and returns the first Panel whose Panel.data is bound to data. This can be useful when you need to inspect Panel.data objects.

      Returns Panel | null

      since

      2.2

    • For "Table" Panels: Returns the cell at a given x-coordinate in local coordinates, or -1 if there are no RowColumnDefinitions for this Table Panel or if the argument is negative. Call GraphObject.getLocalPoint to convert a Point in document coordinates into a Point in local coordinates.

      Parameters

      • x: number

      Returns number

      a zero-based integer

    • Find the Group that perhaps indirectly contains both this part and another one. If this is a Group and it contains the OTHER Part, return this. If the OTHER Part is a Group and it contains this Part, return that OTHER Part.

      This returns null if the two parts are unrelated in the hierarchy of part membership. If non-null, the result is a Group.

      If you want to find the Node that is the tree parent of two Nodes, call Node.findCommonTreeParent.

      Parameters

      Returns Group | null

      may be null

    • Find the Node that is the perhaps indirect tree parent of both this node and another one, or this node if it is an ancestor of the other node, or vice-versa.

      If you want to find the Group that contains two Parts, call Part.findCommonContainingGroup.

      Parameters

      Returns Node | null

      may be null if in different trees, or may be itself if the OTHER argument is THIS node, or may be itself if the OTHER node is a descendant of THIS node, or may be the OTHER node if THIS node is in the tree of the OTHER node.

    • Returns an iterator over all of the Links that connect with this group or any node contained by this group, in either direction, but that are not internal to this group.

      Links that are contained by this group (even in nested groups) are not included in the result collection.

      Returns Iterator<Link>

    • Returns an iterator over all of the Nodes that are connected with this group or any node contained by this group, by a link in either direction, but that are not internal to this group.

      Nodes that are contained by this group (even in nested groups) are not included in the result collection. However this group itself might be in the results if there is a reflexive link connected to this group.

      Returns Iterator<Node>

    • Return the Panel that was made for a particular data object in this panel's itemArray. If this returns a Panel, its data property will be the argument data object, and its containing GraphObject.panel will be this panel.

      Parameters

      • data: ObjectData

        must be a non-null Object, not a string or a number or a boolean or a function

      Returns Panel | null

      or null if not found

    • Returns an iterator over all of the Links that go from this node to another node or vice-versa, perhaps limited to a given port id on this node and a port id on the other node.

      If you want all of the links between two nodes in just one direction, use findLinksTo.

      Parameters

      • othernode: Node
      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      • Optionalotherpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Link>

    • Returns an iterator over all of the Links that connect with this node in either direction, perhaps limited to the given port id on this node.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Link>

    • Returns an iterator over all of the Links that go into this node, perhaps limited to the given port id on this node.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Link>

    • Returns an iterator over all of the Links that come out of this node, perhaps limited to the given port id on this node.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Link>

    • Returns an iterator over all of the Links that go from this node to another node, perhaps limited to a given port id on this node and a port id on the other node.

      If you want all of the links between two nodes in both directions, use findLinksBetween.

      Parameters

      • othernode: Node
      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      • Optionalotherpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Link>

    • Returns an iterator over the Nodes that are connected with this node in either direction, perhaps limited to the given port id on this node.

      The results may include this node itself if there is a reflexive link connecting this node with itself.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Node>

    • Returns an iterator over the Nodes that are connected with this node by links going into this node, perhaps limited to the given port id on this node.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Node>

    • Returns an iterator over the Nodes that are connected with this node by links coming out of this node, perhaps limited to the given port id on this node.

      Parameters

      • Optionalpid: string | null

        A port identifier string; if undefined or null the link's portId is ignored and all links are included in the search.

      Returns Iterator<Node>

    • Find a GraphObject with a given GraphObject.portId. If no such GraphObject is found, search for one with the empty string as its port identifier. Finally, when failing to find a port with either the given name or the empty string, this method returns this whole node itself.

      Parameters

      • pid: string

      Returns GraphObject

    • Walk the graph starting at this Node and collect all of the Nodes and Links accessible by following the Node.findLinksInto, excluding this node itself. Basically this returns a Set of all Nodes and Links that are "upstream" from this Node or are "ancestors" of this Node.

      The graph walk ignores whether Part.isVisible is true. It also ignores Link.isTreeLink and any other tree-specific properties.

      If the graph is tree-structured, you may want to call findTreeParentChain or findTreeParts instead.

      If a visited Node is a Group, the results will not include the member Parts of the Group. If a visited Link has label Nodes, the results will not include them.

      Parameters

      • Optionalresults: Set<Part>

        An optional GSet of Nodes and Links that is returned; if not provided, a new Set is allocated and returned

      Returns Set<Part>

      since

      3.1

    • For "Table" Panels: Returns the row at a given y-coordinate in local coordinates, or -1 if there are no RowColumnDefinitions for this Table Panel or if the argument is negative. Call GraphObject.getLocalPoint to convert a Point in document coordinates into a Point in local coordinates.

      Parameters

      • y: number

      Returns number

      a zero-based integer

    • Return a collection of Parts that are all of the nodes and links that are members of this group, including inside nested groups and label nodes, but excluding this group itself.

      For member nodes that are Groups, this will include its members recursively.

      If you want only the immediate members of this group, use the memberParts property.

      If you want to find the collection of Nodes and Links that are in the subtree of a given Node, use Node.findTreeParts.

      Returns Set<Part>

    • Walk the graph starting at this Node and collect all of the Nodes and Links accessible by following the Node.findLinksOutOf, excluding this node itself. Basically this returns a Set of all Nodes and Links that are "downstream" from this Node or are "descendants" of this Node.

      The graph walk ignores whether Part.isVisible is true. It also ignores Link.isTreeLink and any other tree-specific properties.

      If the graph is tree-structured, you may want to call findTreeParts or findTreeParentChain instead.

      If a visited Node is a Group, the results will not include the member Parts of the Group. If a visited Link has label Nodes, the results will not include them.

      Parameters

      • Optionalresults: Set<Part>

        An optional GSet of Nodes and Links that is returned; if not provided, a new Set is allocated and returned

      Returns Set<Part>

      since

      3.1

    • Finds the top-level Part for this part, which is itself when isTopLevel is true. If this Part is a member of a Group, this returns the top-level Part for that Group. If this is a Node that is a label node for a labeled Link, this returns the top-level Part for that Link.

      If this is a Node and you are searching for the root of the tree that this node is in, use Node.findTreeRoot.

      Returns Part

      This will not return null.

    • Starting with this node, walk up the chain of containingGroups to find a node that is visible. This can be overridden to find a tree-parent/ancestor if the reason that this node is not visible is because of a collapsed tree rather than a collapsed group.

      Returns Node | null

      since

      2.2

    • Returns the effective angle that the object is drawn at, in document coordinates, normalized to between 0 and 360.

      Basically this adds together all of the rotation declared by this angle and the angles of all of its containing Panels, including the Part.

      Returns number

    • Returns the Rect in document coordinates for this object's bounds. If this GraphObject is a Part, the rect will be identical to its actualBounds.

      Parameters

      • Optionalresult: Rect

        an optional Rect that is modified and returned.

      Returns Rect

      in document coordinates.

      since

      2.0

    • Returns the Point in document coordinates for a given Spot in this object's bounds or for a Point in local coordinates.

      For example, for an instance of a Node like this:

      myDiagram.nodeTemplate =
      new go.Node("Auto").add(
      new go.Shape("RoundedRectangle")
      .bind("fill", "color"),
      new go.TextBlock({ name: "TB", margin: 3 })
      .bind("text", "key")
      );

      where the Node is positioned at 100, 200,

        node.findObject("TB").getDocumentPoint(go.Spot.Center)
      

      could return a Point that is approximately at 122, 213.

      Parameters

      • local: Point | Spot

        a real Spot describing a relative location in or near this GraphObject, or a real Point in local coordinates.

      • Optionalresult: Point

        an optional Point that is modified and returned.

      Returns Point

      in document coordinates.

    • Returns the total scale that the object is drawn at, in document coordinates.

      Basically this multiplies together this scale with the scales of all of its containing Panels, including the Part.

      Returns number

    • Given a Point in document coordinates, returns a new Point in local coordinates.

      For example, if you have a mouse event whose InputEvent.documentPoint is at 122, 213, and if you have a Node whose position is at 100, 200, node.getLocalPoint(e.documentPoint) could return a Point that is at 22, 13. For a GraphObject within the Node named "TB",

        node.findObject("TB").getLocalPoint(e.documentPoint)
      

      could return a Point that is at 15.7, 6.7, if that "TB" object is positioned somewhat inside the bounds of the Node.

      Parameters

      • p: Point

        a real Point in document coordinates.

      • Optionalresult: Point

        an optional Point that is modified and returned.

      Returns Point

      The corresponding Point in local coordinates.

    • For "Table" Panels: Gets the RowColumnDefinition for a particular row. If you ask for the definition of a row at or beyond the rowCount, it will automatically create one and return it.

      If this Panel is not a Table Panel, this method returns null.

      Parameters

      • idx: number

        the non-negative zero-based integer row index.

      Returns RowColumnDefinition

    • For "Graduated" Panels: Returns the value that corresponds with the given Point. The Point must be in the panel's coordinates. The value returned will be in the Graduated Panel's range.

      If this Panel is not a Graduated Panel, this method returns NaN.

      Parameters

      • pt: Point

        a Point in the Graduated Panel's coordinates

      Returns number

    • Adds a GraphObject to the Panel's list of elements at the specified index.

      If the element to be added is already in this Panel's list of elements, the object is moved to the specified index. You cannot add a GraphObject to a Panel if that GraphObject is already in a different Panel.

      Parameters

      Returns this

      this

    • Invalidate the Layout that is responsible for positioning this Part. If this part is in a Group, invalidate its Group.layout, if it has one. Otherwise invalidate the Diagram.layout.

      But note that if isLayoutPositioned is false, or if it is in a temporary Layer, or if it is not in a diagram or group, no layout is invalidated.

      Parameters

      • Optionalcondition: number

        the reason that the layout should be invalidated; if this argument is not supplied, any value of layoutConditions other than LayoutConditions.None will allow the layout to be invalidated.

      Returns void

    • This predicate is true if this object is an element, perhaps indirectly, of the given panel.

      For example, if this GraphObject is inside a Part but is not itself the Part, obj.isContainedBy(obj.part) should be true.

      Parameters

      Returns boolean

      true if this object is contained by the given panel, or if it is contained by another panel that is contained by the given panel, to any depth; false if the argument is null or is not a Panel.

    • This predicate is true if this node is a child of the given Node, perhaps indirectly as a descendant.

      If this node is a child of the given node according to Diagram.isTreePathToChildren, this returns true. Otherwise this searches recursively the chain of tree parents of this node, ignoring links for which Link.isTreeLink is false. A node cannot be in its own subtree.

      If you what to find out whether this Node is (perhaps indirectly) contained by a Group, use Part.isMemberOf.

      Parameters

      • node: Node

        the Node that might be a parent or ancestor of this node.

      Returns boolean

      true if the given node is an ancestor of this node, but false otherwise, including false if it is the same node.

    • This predicate is true if this part is a member of the given Part, perhaps indirectly.

      If the given part is a Group and this part is a member of the given group, this returns true. If this part is a Node and it is a label node for a link that is a member of the given group, this returns true. Otherwise this searches recursively any Part.containingGroup of the given part.

      A part cannot be contained by itself. A template should not be a member of any group.

      If this is a Node and you want to find whether it is in a subtree whose root is a given Node, use Node.isInTreeOf.

      Parameters

      Returns boolean

    • This predicate is true if this object is visible and each of its visual containing panels is also visible. This ignores the actual location or appearance (except visibility) of the panel that this object is part of, as well as ignoring all properties of the Layer or Diagram.

      For Parts, you can call the Part.isVisible predicate to determine if not only the Part is visible but also any containing Group or Link or Layer.

      Returns boolean

    • Move this Group and all of its member parts, recursively.

      This method does not perform a transaction or start any animation.

      Parameters

      • newpos: Point

        a new Point in document coordinates.

      • OptionaluseLocation: boolean

        true if you want to set the location instead of the position. False by default.

      Returns void

    • Move this part and any parts that are owned by this part to a new position. This just calls move without the caller having to allocate a new Point.

      Parameters

      • newx: number

        a new X value in document coordinates.

      • newy: number

        a new Y value in document coordinates.

      • OptionaluseLocation: boolean

        true if you want to set the location instead of the position. False by default.

      Returns void

    • Create and add new GraphObjects corresponding to and bound to the data in the itemArray, after removing all existing elements from this Panel. This method is automatically called when replacing the itemArray value, or when changing the value of itemTemplate or itemTemplateMap.

      This uses itemCategoryProperty to determine the category for an item data. That string is used to look up a template in itemTemplateMap. The resulting template (which is also a Panel) is copied, added to this panel, and its itemIndex is set to its index in that Array. That new child Panel is then data-bound to that Array item by setting its data.

      If itemArray is null, this method just removes all elements from this panel. Actually, if this Panel type is "Spot", "Auto", or "Link", the very first element is always kept by this method. Also, if this Panel type is "Table", and if the first element is a "TableRow" or "TableColumn" Panel whose isPanelMain property is set to true, that first element will be kept too. That is useful for defining literal TableRow headers in Table panels, when the header information is not kept as the first item in the itemArray.

      It is wasteful to call this method after making some model data changes. It is better to call Model.set, Model.addArrayItem, Model.insertArrayItem, or Model.removeArrayItem, or other model methods. Not only do those methods update efficiently, they also preserve unbound state and support undo/redo.

      Returns void

    • Removes a GraphObject from this Panel's list of elements.

      Parameters

      Returns this

      this

    • Remove any Adornment of the given category that may be associated with this Part.

      Parameters

      • category: string

        a string identifying the kind or role of the given adornment for this Part.

      Returns void

    • Removes an GraphObject from this Panel's list of elements at the specified index.

      Parameters

      • idx: number

      Returns this

      this

    • For "Table" Panels: Removes the RowColumnDefinition for a particular row.

      If this Panel is not a Table Panel, this method does nothing.

      Parameters

      • idx: number

        the non-negative zero-based integer row index.

      Returns void

    • For "Table" Panels: Removes the RowColumnDefinition for a particular row.

      If this Panel is not a Table Panel, this method does nothing.

      Parameters

      • idx: number

        the non-negative zero-based integer row index.

      Returns void

    • Set any number of properties on this GraphObject. This is common in initialization. This method can only be used to set existing properties on this object. To attach new properties, or to set properties of elements, use GraphObject.attach.

      This method uses TypeScript compile-time type checking, but does no runtime type checking. If you need to set properties without type checking, or attach new properties, use GraphObject.attach.

      // Common init for use in many different shapes:
      const shapeStyle = (() => { return { background: 'red', strokeWidth: 0 }; })

      // Constructor init is equivalent to "set"
      // But if you use common init (eg, shapeStyle())
      // You may wish to set additional properties via "set"
      new go.Shape(shapeStyle())
      .bind("fill", "color")
      .bind("strokeWidth", "width")
      .set({ // more init via set
      figure: "RoundedRectangle"
      })

      Parameters

      • config: Partial<Group> | null

      Returns this

      this GraphObject

      since

      2.2

    • This method sets a collection of properties according to the property/value pairs on the given Object, in the same manner as GraphObject.make does when constructing a GraphObject with an argument that is a simple JavaScript Object.

      This method is common in initialization, but typically you should use set instead, unless you need to attach new properties, or set sub-properties. New property names must start with an underscore "_" character.

      Calling this method is much less efficient than setting properties directly, and does not do compile-time type checking.

      If this is a Panel, you can set properties on named elements within the panel by using a name.property syntax for the property name. For example, if a Node has a Picture that is named "ICON" (because its name property has been set to "ICON") and a TextBlock whose name is "TB", one could set properties on the Node and on each of those named elements by:

      aNode.setProperties({
      background: "red",
      "ICON.source": "https://www.example.com/images/alert.jpg",
      "TB.font": "bold 12pt sans-serif"
      });

      At the current time only a single dot is permitted in the property "name". Note that the use of all-upper-case object names is simply a convention.

      Parameters

      • props: ObjectData

        a plain JavaScript object with various property values to be set on this GraphObject.

      Returns this

      this GraphObject

      see
      • attach a synonym of this method
      • set a type-safe method to set a collection of properties
    • Add a ThemeBinding from a Theme property to a property on this GraphObject.

      Example:

      new go.TextBlock()
      // assigns TextBlock.stroke to the value of theme.colors.text
      .theme("stroke", "text")

      This calls ThemeManager.findTheme to get a Theme object. Because the target property is "stroke", it will use the Theme's "colors" object, Theme.colors. It then retrieves that object's "text" value, which should be a CSS color string or undefined. Finally it sets the target GraphObject, in this case TextBlock.stroke.

      Read more about theming at the Learn page about Themes.

      Parameters

      • targetprop: string

        A string naming the target property on the target object. This should not be the empty string.

      • Optionalsourceprop: string

        A string naming the source property on the theme. This should not be the empty string. If this argument is not supplied, the source property is assumed to be the same as the target property.

      • OptionalthemeSource: string | null

        The theme source object to search for the source property. Supply a property name if the theme property names are in a sub-object of the Object chosen by the targetprop name. See ThemeBinding.themeSource. If this argument is null or not supplied, the empty-string is used.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the source property value to the theme property name. If the function is null or not supplied, no conversion takes place.

      • Optionalthemeconv: TargetConversion

        An optional side-effect-free function converting the theme value to the value to set the target property. See ThemeBinding.themeConverter. If the function is null or not supplied, no conversion takes place. This is infrequently used.

      Returns this

      this GraphObject

      since

      3.0

    • Add a ThemeBinding from a data property to a property on this GraphObject. The data property value should be a theme property name. The theme property value will be the value of that property on the theme source object in the Theme.

      Example:

      new go.TextBlock()
      // assigns TextBlock.stroke to the value of theme.colors[data.state]
      .themeData("stroke", "state")

      It first gets the bound data object's "state" property value, which should be a theme property name. This then calls ThemeManager.findTheme to get a Theme object. Because the target property is "stroke", it will use the Theme's "colors" object, Theme.colors. It then retrieves that object's property value that was named by "state", which should be a CSS color string or undefined. Finally it sets the target GraphObject, in this case TextBlock.stroke.

      Note that if the data property value were instead an actual CSS color string, you would not use themeData because you would not be using themes at all, but just call GraphObject.bind to directly assign the color to the TextBlock.stroke property.

      This is a convenience function for theme that additionally calls ThemeBinding.ofData on the created binding.

      Read more about theming at the Learn page about Themes.

      Parameters

      • targetprop: string

        A string naming the target property on the target object. This should not be the empty string.

      • Optionalsourceprop: string

        A string naming the data source property. This should not be the empty string. If this argument is not supplied, the source property is assumed to be the same as the target property.

      • OptionalthemeSource: string | null

        The theme source object to search for the source property. Supply a property name if the theme property names are in a sub-object of the Object chosen by the targetprop name. See ThemeBinding.themeSource. If this argument is null or not supplied, the empty-string is used.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the source property value to the theme property name. If the function is null or not supplied, no conversion takes place.

      • Optionalthemeconv: TargetConversion

        An optional side-effect-free function converting the theme value to the value to set the target property. See ThemeBinding.themeConverter. If the function is null or not supplied, no conversion takes place. This is infrequently used.

      Returns this

      this GraphObject

      since

      3.0

    • Add a ThemeBinding from the shared Model.modelData to a property on this GraphObject.

      Example:

      new go.TextBlock()
      // assigns TextBlock.stroke to the value of theme.colors[model.modelData.state]
      .themeModel("stroke", "state")

      It first gets the bound data object's "text" property value, which should be a theme property name. This then calls ThemeManager.findTheme to get a Theme object. Because the target property is "stroke", it will use the Theme's "colors" object, Theme.colors. It then retrieves that object's property value that was named by "state", which should be a CSS color string or undefined. Finally it sets the target GraphObject, in this case TextBlock.stroke.

      Note that if the data property value were instead an actual CSS color string, you would not use themeModel because you would not be using themes at all, but just call GraphObject.bindModel to directly assign the color to the TextBlock.stroke property.

      This is a convenience function for theme that additionally calls Binding.ofModel on the created binding.

      Read more about theming at the Learn page about Themes.

      Parameters

      • targetprop: string

        A string naming the target property on the target object. This should not be the empty string.

      • Optionalsourceprop: string

        A string naming the shared model data source property. This should not be the empty string. If this argument is not supplied, the source property is assumed to be the same as the target property.

      • OptionalthemeSource: string | null

        The theme source object to search for the source property. Supply a property name if the theme property names are in a sub-object. See ThemeBinding.themeSource. If this argument is null or not supplied, the empty-string is used.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the source property value to the theme property name. If the function is null or not supplied, no conversion takes place.

      • Optionalthemeconv: TargetConversion

        An optional side-effect-free function converting the theme value to the value to set the target property. See ThemeBinding.themeConverter. If the function is null or not supplied, no conversion takes place. This is infrequently used.

      Returns this

      this GraphObject

      since

      3.0

    • Add a ThemeBinding from a GraphObject property to a property on this GraphObject.

      Example:

      new go.TextBlock()
      // assigns TextBlock.stroke to the value of theme.colors[textblock.text]
      // where the textblock.name == "TB1"
      .themeObject("stroke", "text", null, null, null, "TB1")

      It first finds the element named "TB1", and gets its "text" property value, which should be a theme property name. This then calls ThemeManager.findTheme to get a Theme object. Because the target property is "stroke", it will use the Theme's "colors" object, Theme.colors. It then retrieves that object's property that was named by the TextBlock.text property. Finally it sets the target GraphObject, in this case TextBlock.stroke.

      Note that if the GraphObject property value were instead an actual CSS color string, you would not use themeObject because you would not be using themes at all, but just call GraphObject.bindObject to directly assign the other element's color to the TextBlock.stroke property.

      This is a convenience function for theme that additionally calls Binding.ofObject on the created binding. It passes the objectSrcname param to the Binding.ofObject call. This is infrequently used.

      Read more about theming at the Learn page about Themes.

      Parameters

      • targetprop: string

        A string naming the target property on the target object. This should not be the empty string.

      • Optionalsourceprop: string

        A string naming the GraphObject source property. This should not be the empty string. If this argument is not supplied, the source property is assumed to be the same as the target property.

      • OptionalthemeSource: string | null

        The theme source object to search for the source property. Supply a property name if the theme property names are in a sub-object of the Object chosen by the targetprop name. See ThemeBinding.themeSource. If this argument is null or not supplied, the empty-string is used.

      • Optionalconv: TargetConversion

        An optional side-effect-free function converting the source property value to the theme property name. If the function is null or not supplied, no conversion takes place.

      • Optionalthemeconv: TargetConversion

        An optional side-effect-free function converting the theme value to the value to set the target property. See ThemeBinding.themeConverter. If the function is null or not supplied, no conversion takes place. This is infrequently used.

      • OptionalobjectSrcname: string | null

        the GraphObject.name of an element in the visual tree of the bound Panel If not supplied, it uses the binding Panel as the source GraphObject.

      Returns this

      this GraphObject

      since

      3.0

    • Re-evaluate all data bindings in this Part, in order to assign new property values to the GraphObjects in this visual tree based on this this object's data property values. This method does nothing if data is null.

      It is better to call Model.set to modify data properties, because that will both record changes for undo/redo and will update all bindings that make depend on that property.

      To update relationships between nodes, call updateRelationshipsFromData.

      Parameters

      • Optionalsrcprop: string

        An optional source data property name: when provided, only evaluates those Bindings that use that particular property; when not provided or when it is the empty string, all bindings are evaluated.

      Returns void

    • This static function creates an instance that was defined with GraphObject.defineBuilder. Once this is called one can use the name as the first argument for GraphObject.make. Names are case sensitive.

      The second is an optional settings configuration object, equivalent to calling GraphObject.set on the new object.

      Predefined builder names include: "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", and "ContextMenuButton". The implementation of these builders is provided by Buttons.js in the Extensions directory.

      Type Parameters

      Parameters

      • name: "ContextMenu" | "ToolTip"

        a capitalized name; must not be "" or "None"

      • Optionalconfig: Partial<T> & ObjectData

        a plain JavaScript object with various property values to be set on this GraphObject.

      • ...args: any[]

        If defined in the builder, the additional arguments that would be passed to GraphObject.takeBuilderArgument

      Returns T

      since

      2.2

    • This static function creates an instance that was defined with GraphObject.defineBuilder. Once this is called one can use the name as the first argument for GraphObject.make. Names are case sensitive.

      The second is an optional settings configuration object, equivalent to calling GraphObject.set on the new object.

      Predefined builder names include: "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", and "ContextMenuButton". The implementation of these builders is provided by Buttons.js in the Extensions directory.

      Type Parameters

      Parameters

      • name:
            | "Button"
            | "TreeExpanderButton"
            | "SubGraphExpanderButton"
            | "ContextMenuButton"
            | "PanelExpanderButton"
            | "CheckBoxButton"
            | "CheckBox"

        a capitalized name; must not be "" or "None"

      • Optionalconfig: Partial<T> & ObjectData

        a plain JavaScript object with various property values to be set on this GraphObject.

      • ...args: any[]

        If defined in the builder, the additional arguments that would be passed to GraphObject.takeBuilderArgument

      Returns T

      since

      2.2

    • This static function creates an instance that was defined with GraphObject.defineBuilder. Once this is called one can use the name as the first argument for GraphObject.make. Names are case sensitive.

      The second is an optional settings configuration object, equivalent to calling GraphObject.set on the new object.

      Predefined builder names include: "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", and "ContextMenuButton". The implementation of these builders is provided by Buttons.js in the Extensions directory.

      Type Parameters

      Parameters

      • name: string

        a capitalized name; must not be "" or "None"

      • Optionalconfig: Partial<T> & ObjectData

        a plain JavaScript object with various property values to be set on this GraphObject.

      • ...args: any[]

        If defined in the builder, the additional arguments that would be passed to GraphObject.takeBuilderArgument

      Returns T

      since

      2.2

    • This static function defines a named function that GraphObject.make or GraphObject.build can use to build objects. Once this is called one can use the name as the first argument for GraphObject.make or GraphObject.build. Names are case sensitive.

      The second argument must be a function that returns a newly created object, typically a GraphObject. It is commonplace for that object to be a Panel holding a newly created visual tree of GraphObjects. The function receives as its only argument an Array that is holds all of the arguments that are being passed to GraphObject.make, which it may modify in order to change the arguments that GraphObject.make receives.

      You can determine whether or not a builder name has already been defnied by calling the static function GraphObject.isBuilderDefined.

      Predefined builder names include: "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", and "ContextMenuButton". The implementation of these builders is provided by Buttons.js in the Extensions directory.

      Parameters

      • name: string

        a capitalized name; must not be "" or "None"

      • func: (a: any[]) => ObjectData

        that takes an Array of GraphObject.make arguments and returns a new object

      Returns void

    • Register a PanelLayout. This is called when making new Panel types. See the PanelLayout sample for an example. PanelLayout names can be used as the first argument to a Panel constructor.

      You can determine whether or not a builder name has already been defnied by calling the static function Panel.isLayoutDefined.

      Parameters

      • layoutName: string

        Panel name

      • layout: PanelLayout

        instance of the PanelLayout

      Returns void

      since

      2.0

    • This static predicate is true if and only if GraphObject.defineBuilder has been called on the given name. Such names can be used as the first argument to the static function GraphObject.build.

      Parameters

      • name: string

      Returns boolean

      since

      3.1

    • This static predicate is true if and only if Panel.definePanelLayout has been called on the given name. Such names can be used as the first argument of the Panel constructor.

      Parameters

      • name: string

      Returns boolean

      since

      3.1

    • This static function builds an object given its class and additional arguments providing initial properties or GraphObjects that become Panel elements.

      The first argument must be the class type or the name of a class or the name of a predefined kind of Panel. This function will construct a new instance of that type and use the rest of the arguments to initialize the object. The first argument cannot be a regular Object (such as a GraphObject) that you are trying to initialize; for that you can call setProperties or Diagram.setProperties, although that would be less efficient than setting properties directly.

      If an initializer argument is an enumerated value, this tries to set the property that seems most appropriate.

      If an initializer argument is a string, this sets a particular property depending on the type of object being built.

      If an initializer argument is a particular kind of object, this can add that object to the object being built.

      When the initializer argument is a plain JavaScript Object, there are several ways that that object's properties are applied. If the property name is a string with a period inside it, this has a special meaning if the object is a Panel or a Diagram. At the current time only a single period separator is valid syntax for a property string, and it is valid only on Panels and Diagrams.

      For Panels, the substring before the period is used as the name passed to Panel.findObject to get the actual object on which to set the property, which is the substring after the period. This is normally useful only on the predefined Panels:

      • a "Button" has a Shape named "ButtonBorder" surrounding the content of the Panel.
      • a "TreeExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "SubGraphExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "ContextMenuButton" has a Shape named "ButtonBorder" surrounding the content of the Panel.

      But you can define your own names that GraphObject.make can build by calling the static function GraphObject.defineBuilder.

      For Diagrams, the substring before the period is used as the name of a property on the Diagram itself to get the actual object on which to set the property. As a special case, if such a property value does not exist on the Diagram, it looks on the Diagram.toolManager. See some examples below.

      Also for Diagrams, and only for Diagrams, if the property name is the name of a DiagramEvent, the property value must be a DiagramEvent listener function, and Diagram.addDiagramListener is called using that DiagramEvent name and that function. Note that all DiagramEvent names are capitalized and do not contain any periods, so there cannot be any name conflicts with any properties on Diagram or ToolManager. Although you can register multiple listeners for the same DiagramEvent names, due to JavaScript limitations those need to be declared using separate JavaScript objects, because JavaScript does not permit duplicate property names in an Object literal.

      Furthermore for Diagrams, if the property name is "Changed" or "ModelChanged", the property value must be a ChangedEvent listener function, which is called with a ChangedEvent argument. When the property name is "Changed", it calls Diagram.addChangedListener, notifying about changes to the Diagram or its Layers or GraphObjects. When the property name is "ModelChanged", it calls Model.addChangedListener on the Diagram.model, resulting in notifications about changes to the Model or its data. This is handy because the Diagram.model property setter will automatically call Model.removeChangedListener on the old model, thereby avoiding any overhead if there are any more changes to the old model and also avoiding a reference to the listener which might cause garbage collection retention. It also will call Model.addChangedListener on the new model, helping implement the same behavior with the new model.

      If the property name is a number and if the object being constructed is a Brush, the number and value are added to the Brush by calling Brush.addColorStop.

      Otherwise the property name is used as a regular property name on the object being built. This tries to do some property name and value checking: when a property is not defined on the object being built, it will signal an error. Many typos can be found this way that would be ignored by JavaScript code.

      If the property name begins with an underscore, this will not complain about the property being undefined. Not only is that underscore property set on the object being built, but calls to copy will also copy the values of such named properties to the new objects.

       const diagram =
      new go.Diagram("myDiagramDiv",
      {
      // don't initialize some properties until after a new model has been loaded
      "InitialLayoutCompleted": loadDiagramProperties,
      allowZoom: false, // don't allow the user to change the diagram's scale
      "grid.visible": true, // display a background grid for the whole diagram
      "grid.gridCellSize": new go.Size(20, 20),
      // allow double-click in background to create a new node
      "clickCreatingTool.archetypeNodeData": { text: "Node" },
      // allow Ctrl-G to call the groupSelection command
      "commandHandler.archetypeGroupData":
      { text: "Group", isGroup: true, color: "blue" },
      "toolManager.hoverDelay": 100, // how quickly tooltips are shown
      // mouse wheel zooms instead of scrolls
      "toolManager.mouseWheelBehavior": go.WheelMode.Zoom,
      "commandHandler.copiesTree": true, // for the copy command
      "commandHandler.deletesTree": true, // for the delete command
      "draggingTool.dragsTree": true, // dragging for both move and copy
      "draggingTool.isGridSnapEnabled": true,
      layout: new go.TreeLayout(
      { angle: 90, sorting: go.TreeLayout.SortingAscending })
      });

      diagram.nodeTemplate =
      new go.Node("Auto") // or go.Panel.Auto
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify).add(
      new go.Shape("RoundedRectangle",
      {
      fill: new go.Brush("Linear", { 0: "#FEC901", 1: "#FEA200" }),
      stroke: "gray",
      strokeWidth: 2,
      strokeDashArray: [3, 3]
      }),
      new go.TextBlock(
      { margin: 5, font: "bold 12pt sans-serif" })
      .bind("text", "key")
      );

      See the Learn page on building objects for usage information and examples of GraphObject.make.

      Type Parameters

      Parameters

      • cls: "ContextMenu" | "ToolTip"

        a class function or the name of a class in the go namespace, or one of several predefined kinds of Panels: "Button", "TreeExpanderButton", "SubGraphExpanderButton", or "ContextMenuButton".

      • ...initializers: (
            | string
            | number
            | PanelLayout
            | Binding
            | AnimationTrigger
            | Partial<GraphObject> & { [p: string]: any }
            | RowColumnDefinition
            | (
                | string
                | number
                | PanelLayout
                | Binding
                | AnimationTrigger
                | RowColumnDefinition
                | Partial<GraphObject> & { [p: string]: any }
            )[]
        )[]

        zero or more values that initialize the new object, typically an Object with properties whose values are set on the new object, or a JavaScript Array with additional initializer arguments, or a GraphObject that is added to a Panel, or a Binding for one of the new object's properties, or a constant value as the initial value of a single property of the new object that is recognized to take that value, or a string that is used as the value of a commonly set property.

      Returns T

    • This static function builds an object given its class and additional arguments providing initial properties or GraphObjects that become Panel elements.

      The first argument must be the class type or the name of a class or the name of a predefined kind of Panel. This function will construct a new instance of that type and use the rest of the arguments to initialize the object. The first argument cannot be a regular Object (such as a GraphObject) that you are trying to initialize; for that you can call setProperties or Diagram.setProperties, although that would be less efficient than setting properties directly.

      If an initializer argument is an enumerated value, this tries to set the property that seems most appropriate.

      If an initializer argument is a string, this sets a particular property depending on the type of object being built.

      If an initializer argument is a particular kind of object, this can add that object to the object being built.

      When the initializer argument is a plain JavaScript Object, there are several ways that that object's properties are applied. If the property name is a string with a period inside it, this has a special meaning if the object is a Panel or a Diagram. At the current time only a single period separator is valid syntax for a property string, and it is valid only on Panels and Diagrams.

      For Panels, the substring before the period is used as the name passed to Panel.findObject to get the actual object on which to set the property, which is the substring after the period. This is normally useful only on the predefined Panels:

      • a "Button" has a Shape named "ButtonBorder" surrounding the content of the Panel.
      • a "TreeExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "SubGraphExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "ContextMenuButton" has a Shape named "ButtonBorder" surrounding the content of the Panel.

      But you can define your own names that GraphObject.make can build by calling the static function GraphObject.defineBuilder.

      For Diagrams, the substring before the period is used as the name of a property on the Diagram itself to get the actual object on which to set the property. As a special case, if such a property value does not exist on the Diagram, it looks on the Diagram.toolManager. See some examples below.

      Also for Diagrams, and only for Diagrams, if the property name is the name of a DiagramEvent, the property value must be a DiagramEvent listener function, and Diagram.addDiagramListener is called using that DiagramEvent name and that function. Note that all DiagramEvent names are capitalized and do not contain any periods, so there cannot be any name conflicts with any properties on Diagram or ToolManager. Although you can register multiple listeners for the same DiagramEvent names, due to JavaScript limitations those need to be declared using separate JavaScript objects, because JavaScript does not permit duplicate property names in an Object literal.

      Furthermore for Diagrams, if the property name is "Changed" or "ModelChanged", the property value must be a ChangedEvent listener function, which is called with a ChangedEvent argument. When the property name is "Changed", it calls Diagram.addChangedListener, notifying about changes to the Diagram or its Layers or GraphObjects. When the property name is "ModelChanged", it calls Model.addChangedListener on the Diagram.model, resulting in notifications about changes to the Model or its data. This is handy because the Diagram.model property setter will automatically call Model.removeChangedListener on the old model, thereby avoiding any overhead if there are any more changes to the old model and also avoiding a reference to the listener which might cause garbage collection retention. It also will call Model.addChangedListener on the new model, helping implement the same behavior with the new model.

      If the property name is a number and if the object being constructed is a Brush, the number and value are added to the Brush by calling Brush.addColorStop.

      Otherwise the property name is used as a regular property name on the object being built. This tries to do some property name and value checking: when a property is not defined on the object being built, it will signal an error. Many typos can be found this way that would be ignored by JavaScript code.

      If the property name begins with an underscore, this will not complain about the property being undefined. Not only is that underscore property set on the object being built, but calls to copy will also copy the values of such named properties to the new objects.

       const diagram =
      new go.Diagram("myDiagramDiv",
      {
      // don't initialize some properties until after a new model has been loaded
      "InitialLayoutCompleted": loadDiagramProperties,
      allowZoom: false, // don't allow the user to change the diagram's scale
      "grid.visible": true, // display a background grid for the whole diagram
      "grid.gridCellSize": new go.Size(20, 20),
      // allow double-click in background to create a new node
      "clickCreatingTool.archetypeNodeData": { text: "Node" },
      // allow Ctrl-G to call the groupSelection command
      "commandHandler.archetypeGroupData":
      { text: "Group", isGroup: true, color: "blue" },
      "toolManager.hoverDelay": 100, // how quickly tooltips are shown
      // mouse wheel zooms instead of scrolls
      "toolManager.mouseWheelBehavior": go.WheelMode.Zoom,
      "commandHandler.copiesTree": true, // for the copy command
      "commandHandler.deletesTree": true, // for the delete command
      "draggingTool.dragsTree": true, // dragging for both move and copy
      "draggingTool.isGridSnapEnabled": true,
      layout: new go.TreeLayout(
      { angle: 90, sorting: go.TreeLayout.SortingAscending })
      });

      diagram.nodeTemplate =
      new go.Node("Auto") // or go.Panel.Auto
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify).add(
      new go.Shape("RoundedRectangle",
      {
      fill: new go.Brush("Linear", { 0: "#FEC901", 1: "#FEA200" }),
      stroke: "gray",
      strokeWidth: 2,
      strokeDashArray: [3, 3]
      }),
      new go.TextBlock(
      { margin: 5, font: "bold 12pt sans-serif" })
      .bind("text", "key")
      );

      See the Learn page on building objects for usage information and examples of GraphObject.make.

      Type Parameters

      Parameters

      • cls:
            | "Button"
            | "TreeExpanderButton"
            | "SubGraphExpanderButton"
            | "ContextMenuButton"
            | "PanelExpanderButton"
            | "CheckBoxButton"
            | "CheckBox"

        a class function or the name of a class in the go namespace, or one of several predefined kinds of Panels: "Button", "TreeExpanderButton", "SubGraphExpanderButton", or "ContextMenuButton".

      • ...initializers: (
            | string
            | number
            | PanelLayout
            | Binding
            | AnimationTrigger
            | RowColumnDefinition
            | Partial<GraphObject> & { [p: string]: any }
            | (
                | string
                | number
                | PanelLayout
                | Binding
                | AnimationTrigger
                | RowColumnDefinition
                | Partial<GraphObject> & { [p: string]: any }
            )[]
        )[]

        zero or more values that initialize the new object, typically an Object with properties whose values are set on the new object, or a JavaScript Array with additional initializer arguments, or a GraphObject that is added to a Panel, or a Binding for one of the new object's properties, or a constant value as the initial value of a single property of the new object that is recognized to take that value, or a string that is used as the value of a commonly set property.

      Returns T

    • This static function builds an object given its class and additional arguments providing initial properties or GraphObjects that become Panel elements.

      The first argument must be the class type or the name of a class or the name of a predefined kind of Panel. This function will construct a new instance of that type and use the rest of the arguments to initialize the object. The first argument cannot be a regular Object (such as a GraphObject) that you are trying to initialize; for that you can call setProperties or Diagram.setProperties, although that would be less efficient than setting properties directly.

      If an initializer argument is an enumerated value, this tries to set the property that seems most appropriate.

      If an initializer argument is a string, this sets a particular property depending on the type of object being built.

      If an initializer argument is a particular kind of object, this can add that object to the object being built.

      When the initializer argument is a plain JavaScript Object, there are several ways that that object's properties are applied. If the property name is a string with a period inside it, this has a special meaning if the object is a Panel or a Diagram. At the current time only a single period separator is valid syntax for a property string, and it is valid only on Panels and Diagrams.

      For Panels, the substring before the period is used as the name passed to Panel.findObject to get the actual object on which to set the property, which is the substring after the period. This is normally useful only on the predefined Panels:

      • a "Button" has a Shape named "ButtonBorder" surrounding the content of the Panel.
      • a "TreeExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "SubGraphExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "ContextMenuButton" has a Shape named "ButtonBorder" surrounding the content of the Panel.

      But you can define your own names that GraphObject.make can build by calling the static function GraphObject.defineBuilder.

      For Diagrams, the substring before the period is used as the name of a property on the Diagram itself to get the actual object on which to set the property. As a special case, if such a property value does not exist on the Diagram, it looks on the Diagram.toolManager. See some examples below.

      Also for Diagrams, and only for Diagrams, if the property name is the name of a DiagramEvent, the property value must be a DiagramEvent listener function, and Diagram.addDiagramListener is called using that DiagramEvent name and that function. Note that all DiagramEvent names are capitalized and do not contain any periods, so there cannot be any name conflicts with any properties on Diagram or ToolManager. Although you can register multiple listeners for the same DiagramEvent names, due to JavaScript limitations those need to be declared using separate JavaScript objects, because JavaScript does not permit duplicate property names in an Object literal.

      Furthermore for Diagrams, if the property name is "Changed" or "ModelChanged", the property value must be a ChangedEvent listener function, which is called with a ChangedEvent argument. When the property name is "Changed", it calls Diagram.addChangedListener, notifying about changes to the Diagram or its Layers or GraphObjects. When the property name is "ModelChanged", it calls Model.addChangedListener on the Diagram.model, resulting in notifications about changes to the Model or its data. This is handy because the Diagram.model property setter will automatically call Model.removeChangedListener on the old model, thereby avoiding any overhead if there are any more changes to the old model and also avoiding a reference to the listener which might cause garbage collection retention. It also will call Model.addChangedListener on the new model, helping implement the same behavior with the new model.

      If the property name is a number and if the object being constructed is a Brush, the number and value are added to the Brush by calling Brush.addColorStop.

      Otherwise the property name is used as a regular property name on the object being built. This tries to do some property name and value checking: when a property is not defined on the object being built, it will signal an error. Many typos can be found this way that would be ignored by JavaScript code.

      If the property name begins with an underscore, this will not complain about the property being undefined. Not only is that underscore property set on the object being built, but calls to copy will also copy the values of such named properties to the new objects.

       const diagram =
      new go.Diagram("myDiagramDiv",
      {
      // don't initialize some properties until after a new model has been loaded
      "InitialLayoutCompleted": loadDiagramProperties,
      allowZoom: false, // don't allow the user to change the diagram's scale
      "grid.visible": true, // display a background grid for the whole diagram
      "grid.gridCellSize": new go.Size(20, 20),
      // allow double-click in background to create a new node
      "clickCreatingTool.archetypeNodeData": { text: "Node" },
      // allow Ctrl-G to call the groupSelection command
      "commandHandler.archetypeGroupData":
      { text: "Group", isGroup: true, color: "blue" },
      "toolManager.hoverDelay": 100, // how quickly tooltips are shown
      // mouse wheel zooms instead of scrolls
      "toolManager.mouseWheelBehavior": go.WheelMode.Zoom,
      "commandHandler.copiesTree": true, // for the copy command
      "commandHandler.deletesTree": true, // for the delete command
      "draggingTool.dragsTree": true, // dragging for both move and copy
      "draggingTool.isGridSnapEnabled": true,
      layout: new go.TreeLayout(
      { angle: 90, sorting: go.TreeLayout.SortingAscending })
      });

      diagram.nodeTemplate =
      new go.Node("Auto") // or go.Panel.Auto
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify).add(
      new go.Shape("RoundedRectangle",
      {
      fill: new go.Brush("Linear", { 0: "#FEC901", 1: "#FEA200" }),
      stroke: "gray",
      strokeWidth: 2,
      strokeDashArray: [3, 3]
      }),
      new go.TextBlock(
      { margin: 5, font: "bold 12pt sans-serif" })
      .bind("text", "key")
      );

      See the Learn page on building objects for usage information and examples of GraphObject.make.

      Type Parameters

      Parameters

      • cls: string

        a class function or the name of a class in the go namespace, or one of several predefined kinds of Panels: "Button", "TreeExpanderButton", "SubGraphExpanderButton", or "ContextMenuButton".

      • ...initializers: (
            | string
            | number
            | PanelLayout
            | Binding
            | AnimationTrigger
            | RowColumnDefinition
            | Partial<GraphObject> & { [p: string]: any }
            | (
                | string
                | number
                | PanelLayout
                | Binding
                | AnimationTrigger
                | RowColumnDefinition
                | Partial<GraphObject> & { [p: string]: any }
            )[]
        )[]

        zero or more values that initialize the new object, typically an Object with properties whose values are set on the new object, or a JavaScript Array with additional initializer arguments, or a GraphObject that is added to a Panel, or a Binding for one of the new object's properties, or a constant value as the initial value of a single property of the new object that is recognized to take that value, or a string that is used as the value of a commonly set property.

      Returns T

    • This static function builds an object given its class and additional arguments providing initial properties or GraphObjects that become Panel elements.

      The first argument must be the class type or the name of a class or the name of a predefined kind of Panel. This function will construct a new instance of that type and use the rest of the arguments to initialize the object. The first argument cannot be a regular Object (such as a GraphObject) that you are trying to initialize; for that you can call setProperties or Diagram.setProperties, although that would be less efficient than setting properties directly.

      If an initializer argument is an enumerated value, this tries to set the property that seems most appropriate.

      If an initializer argument is a string, this sets a particular property depending on the type of object being built.

      If an initializer argument is a particular kind of object, this can add that object to the object being built.

      When the initializer argument is a plain JavaScript Object, there are several ways that that object's properties are applied. If the property name is a string with a period inside it, this has a special meaning if the object is a Panel or a Diagram. At the current time only a single period separator is valid syntax for a property string, and it is valid only on Panels and Diagrams.

      For Panels, the substring before the period is used as the name passed to Panel.findObject to get the actual object on which to set the property, which is the substring after the period. This is normally useful only on the predefined Panels:

      • a "Button" has a Shape named "ButtonBorder" surrounding the content of the Panel.
      • a "TreeExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "SubGraphExpanderButton" has a "ButtonBorder" Shape and a "ButtonIcon" Shape that is the plus-or-minus sign.
      • a "ContextMenuButton" has a Shape named "ButtonBorder" surrounding the content of the Panel.

      But you can define your own names that GraphObject.make can build by calling the static function GraphObject.defineBuilder.

      For Diagrams, the substring before the period is used as the name of a property on the Diagram itself to get the actual object on which to set the property. As a special case, if such a property value does not exist on the Diagram, it looks on the Diagram.toolManager. See some examples below.

      Also for Diagrams, and only for Diagrams, if the property name is the name of a DiagramEvent, the property value must be a DiagramEvent listener function, and Diagram.addDiagramListener is called using that DiagramEvent name and that function. Note that all DiagramEvent names are capitalized and do not contain any periods, so there cannot be any name conflicts with any properties on Diagram or ToolManager. Although you can register multiple listeners for the same DiagramEvent names, due to JavaScript limitations those need to be declared using separate JavaScript objects, because JavaScript does not permit duplicate property names in an Object literal.

      Furthermore for Diagrams, if the property name is "Changed" or "ModelChanged", the property value must be a ChangedEvent listener function, which is called with a ChangedEvent argument. When the property name is "Changed", it calls Diagram.addChangedListener, notifying about changes to the Diagram or its Layers or GraphObjects. When the property name is "ModelChanged", it calls Model.addChangedListener on the Diagram.model, resulting in notifications about changes to the Model or its data. This is handy because the Diagram.model property setter will automatically call Model.removeChangedListener on the old model, thereby avoiding any overhead if there are any more changes to the old model and also avoiding a reference to the listener which might cause garbage collection retention. It also will call Model.addChangedListener on the new model, helping implement the same behavior with the new model.

      If the property name is a number and if the object being constructed is a Brush, the number and value are added to the Brush by calling Brush.addColorStop.

      Otherwise the property name is used as a regular property name on the object being built. This tries to do some property name and value checking: when a property is not defined on the object being built, it will signal an error. Many typos can be found this way that would be ignored by JavaScript code.

      If the property name begins with an underscore, this will not complain about the property being undefined. Not only is that underscore property set on the object being built, but calls to copy will also copy the values of such named properties to the new objects.

       const diagram =
      new go.Diagram("myDiagramDiv",
      {
      // don't initialize some properties until after a new model has been loaded
      "InitialLayoutCompleted": loadDiagramProperties,
      allowZoom: false, // don't allow the user to change the diagram's scale
      "grid.visible": true, // display a background grid for the whole diagram
      "grid.gridCellSize": new go.Size(20, 20),
      // allow double-click in background to create a new node
      "clickCreatingTool.archetypeNodeData": { text: "Node" },
      // allow Ctrl-G to call the groupSelection command
      "commandHandler.archetypeGroupData":
      { text: "Group", isGroup: true, color: "blue" },
      "toolManager.hoverDelay": 100, // how quickly tooltips are shown
      // mouse wheel zooms instead of scrolls
      "toolManager.mouseWheelBehavior": go.WheelMode.Zoom,
      "commandHandler.copiesTree": true, // for the copy command
      "commandHandler.deletesTree": true, // for the delete command
      "draggingTool.dragsTree": true, // dragging for both move and copy
      "draggingTool.isGridSnapEnabled": true,
      layout: new go.TreeLayout(
      { angle: 90, sorting: go.TreeLayout.SortingAscending })
      });

      diagram.nodeTemplate =
      new go.Node("Auto") // or go.Panel.Auto
      .bindTwoWay("location", "loc", go.Point.parse, go.Point.stringify).add(
      new go.Shape("RoundedRectangle",
      {
      fill: new go.Brush("Linear", { 0: "#FEC901", 1: "#FEA200" }),
      stroke: "gray",
      strokeWidth: 2,
      strokeDashArray: [3, 3]
      }),
      new go.TextBlock(
      { margin: 5, font: "bold 12pt sans-serif" })
      .bind("text", "key")
      );

      See the Learn page on building objects for usage information and examples of GraphObject.make.

      Type Parameters

      • CT extends ConstructorType<CT>

      Parameters

      Returns InstanceType<CT>

    • This static function returns the first argument from the arguments array passed to a GraphObject.defineBuilder function by GraphObject.make. By default this requires the first argument to be a string, but you can provide a predicate to determine whether the argument is suitable.

      Parameters

      • args: any[]

        the arguments Array passed to the builder function; this may be modified if an acceptable argument is found and returned

      • Optionaldefval: any

        the default value to return if the argument is optional and not present as the first argument; otherwise throw an error when the argument is not there

      • Optionalpred: ((a: any) => boolean) | null

        a predicate to determine the acceptability of the argument; the default predicate checks whether the argument is a string

      Returns any

    Properties

    Auto: PanelLayout = ...

    Returns a 'Auto' PanelLayout, a possible value for Panel.type.

    Default: 1
    Fill: 2
    FlipBoth: Both = Flip.Both
    deprecated

    See Flip.Both.

    FlipHorizontal: Horizontal = Flip.Horizontal
    deprecated

    See Flip.Horizontal.

    FlipVertical: Vertical = Flip.Vertical
    deprecated

    See Flip.Vertical.

    Graduated: PanelLayout = ...

    Returns a 'Graduated' PanelLayout, a possible value for Panel.type.

    Grid: PanelLayout = ...

    Returns a 'Grid' PanelLayout, a possible value for Panel.type.

    Horizontal: PanelLayout = ...

    Returns a 'Horizontal' PanelLayout, a possible value for Panel.type.

    LayoutAdded: Added = LayoutConditions.Added
    deprecated

    See LayoutConditions.Added.

    LayoutGroupLayout: GroupLayout = LayoutConditions.GroupLayout
    LayoutHidden: Hidden = LayoutConditions.Hidden
    deprecated

    See LayoutConditions.Hidden.

    LayoutNodeReplaced: NodeReplaced = LayoutConditions.NodeReplaced
    LayoutNodeSized: NodeSized = LayoutConditions.NodeSized
    LayoutNone: None = LayoutConditions.None
    deprecated

    See LayoutConditions.None.

    LayoutRemoved: Removed = LayoutConditions.Removed
    deprecated

    See LayoutConditions.Removed.

    LayoutShown: Shown = LayoutConditions.Shown
    deprecated

    See LayoutConditions.Shown.

    LayoutStandard: Standard = LayoutConditions.Standard
    Link: PanelLayout = ...

    Returns a 'Link' PanelLayout, a possible value for Panel.type.

    None: 0
    Position: PanelLayout = ...

    Returns a 'Position' PanelLayout, a possible value for Panel.type.

    Spot: PanelLayout = ...

    Returns a 'Spot' PanelLayout, a possible value for Panel.type.

    SpreadingEvenly: Evenly = PortSpreading.Evenly
    deprecated

    See PortSpreading.Evenly.

    SpreadingNone: None = PortSpreading.None
    deprecated

    See PortSpreading.None.

    SpreadingPacked: Packed = PortSpreading.Packed
    deprecated

    See PortSpreading.Packed.

    Table: PanelLayout = ...

    Returns a 'Table' PanelLayout, a possible value for Panel.type.

    TableColumn: PanelLayout = ...

    Returns a 'TableColumn' PanelLayout, a possible value for Panel.type.

    TableRow: PanelLayout = ...

    Returns a 'TableRow' PanelLayout, a possible value for Panel.type.

    Uniform: 6
    UniformToFill: 7
    Vertical: PanelLayout = ...

    Returns a 'Vertical' PanelLayout, a possible value for Panel.type.

    Viewbox: PanelLayout = ...

    Returns a 'Viewbox' PanelLayout, a possible value for Panel.type.