Diagram class

A Diagram is associated with an HTML DIV element. Constructing a Diagram creates an HTML Canvas element which it places inside of the given DIV element, in addition to several helper DIVs. GoJS will manage the contents of this DIV -- you should not modify the contents of the DIV, although you may style the given DIV (background, border, etc) and position and size it as needed.

Minimal Diagram construction looks like this. HTML:

<div id="myDiagramDiv" style="border: solid 1px black; width:400px; height:400px"></div>

JavaScript:


myDiagram = new go.Diagram("myDiagramDiv",  // create a Diagram for the DIV HTML element
              {
                "undoManager.isEnabled": true  // enable undo & redo
              });

The diagram will draw onto an HTML Canvas element, created inside the Diagram DIV.

Each Diagram holds a set of Layers each of which holds some number of Parts such as Nodes and Links. Each Part consists of GraphObjects such as TextBlocks and Shapes and Panels holding yet more GraphObjects.

A Diagram and its Parts provide the visual representation of a Model that holds JavaScript data objects for the nodes and the links. The model provides the way to recognize the relationships between the data.

Two Diagrams can display and manipulate the same Model. (Example)

A diagram will automatically create Nodes and Links corresponding to the model data. The diagram has a number of named templates it uses to create the actual parts: #nodeTemplateMap, #groupTemplateMap, and #linkTemplateMap. Each template may have some data Bindings that set the part's GraphObjects' properties based on the value of properties of the data.

A simple Node template and Model data (both nodes and links) may look like this:

var $ = go.GraphObject.make;  // for conciseness

// define a simple Node template
myDiagram.nodeTemplate =
  $(go.Node, "Auto",  // the Shape will go around the TextBlock
    $(go.Shape, "RoundedRectangle",
      // Shape.fill is bound to Node.data.color
      new go.Binding("fill", "color")),
    $(go.TextBlock,
      { margin: 3 },  // some room around the text
      // TextBlock.text is bound to Node.data.key
      new go.Binding("text", "key"))
  );

// create the model data that will be represented by Nodes and Links
myDiagram.model = new go.GraphLinksModel(
[
  { key: "Alpha", color: "lightblue" },
  { key: "Beta", color: "orange" },
  { key: "Gamma", color: "lightgreen" },
  { key: "Delta", color: "pink" }
],
[
  { from: "Alpha", to: "Beta" },
  { from: "Alpha", to: "Gamma" },
  { from: "Beta", to: "Beta" },
  { from: "Gamma", to: "Delta" },
  { from: "Delta", to: "Alpha" }
]);

The above code is used to make the Minimal sample, a simple example of creating a Diagram and setting its model.

Read about models on the Using Models page in the introduction. A diagram is responsible for scrolling (#position) and zooming (#scale) all of the parts that it shows. Each Part occupies some area given by its GraphObject#actualBounds.

The union of all of the parts' bounds constitutes the #documentBounds. The document bounds determines the area that the diagram can be scrolled to. There are several properties that you can set, such as #initialContentAlignment, that control the initial size and position of the diagram contents.

At any later time you can also explicitly set the #position and/or #scale to get the appearance that you want. But you may find it easier to call methods to get the desired effect. For example, if you want to make a particular Node be centered in the viewport, call either #centerRect or #scrollToRect with the Node's GraphObject#actualBounds, depending on whether or not you want the view to be scrolled if the node is already in view.

Read in the Introduction about Viewports and the Initial Viewport. You can have the diagram perform automatic layouts of its nodes and links by setting #layout to an instance of the Layout subclass of your choice. The default #layout is an instance of the Layout base class that ignores links and only positions Nodes that do not have a location. This default layout will allow you to programmatically position nodes (including by loading from a database) and will also allow the user to manually position nodes using the DraggingTool.

If you do supply a particular layout as the #layout, you can control which Parts it operates on by setting Part#isLayoutPositioned. Normally, of course, it works on all top-level nodes and links. The layout is performed both after the model is first loaded as well as after any part is added or removed or changes visibility or size. You can disable the initial layout by setting Layout#isInitial to false. You can disable later automatic layouts by setting Layout#isOngoing to false.

See the Layouts page in the Introduction for a summary of layout behavior.

A diagram maintains a collection of selected parts, the Diagram#selection. To select a Part you set its Part#isSelected property to true.

There are many properties, named "allow...", that control what operations the user may perform on the parts in the diagram. These correspond to the same named properties on Layer that govern the behavior for those parts in a particular layer. Furthermore for some of these properties there are corresponding properties on Part, named "...able", that govern the behavior for that individual part. For example, the #allowCopy property corresponds to Layer#allowCopy and to the property Part#copyable. The Part#canCopy predicate is false if any of these properties is false.

See the Permissions page for a more thorough discussion.

The #commandHandler implements various standard commands, such as the CommandHandler#deleteSelection method and the CommandHandler#canDeleteSelection predicate.

See the Commands page for a listing of keyboard commands and the use of commands in general.

The diagram supports modular behavior for mouse events by implementing "tools". All mouse and keyboard events are represented by InputEvents and redirected to the #currentTool. The default tool is an instance of ToolManager which keeps three lists of mode-less tools: ToolManager#mouseDownTools, ToolManager#mouseMoveTools, and ToolManager#mouseUpTools. The ToolManager searches these lists when a mouse event happens to find the first tool that can run. It then makes that tool the new #currentTool, where it can continue to process input events. When the tool is done, it stops itself, causing the #defaultTool to be the new #currentTool.

Mouse-down tools include:

  • ToolManager#actionTool, to support objects like "buttons"
  • ToolManager#relinkingTool, to reconnect an existing link
  • ToolManager#linkReshapingTool, to modify the route of an existing link
  • ToolManager#rotatingTool, to change the angle of an object
  • ToolManager#resizingTool, to change the size of an object

Mouse-move tools include:

  • ToolManager#linkingTool, to draw a new link
  • ToolManager#draggingTool, to move or copy the selection
  • ToolManager#dragSelectingTool, to select parts within a rectangular area
  • ToolManager#panningTool, to pan the diagram

Mouse-up tools include:

  • ToolManager#contextMenuTool, to manage context menus
  • ToolManager#textEditingTool, to support in-place text editing
  • ToolManager#clickCreatingTool, to create new parts where the user clicks
  • ToolManager#clickSelectingTool, to select parts

You can also run a tool in a modal fashion by explicitly setting #currentTool. That tool will keep running until some code replaces the #currentTool. This normally happens when the current tool calls Tool#stopTool, such as on a mouse-up event.

See the Tools page for a listing of predefined tools and how they operate.

A diagram raises various DiagramEvents when interesting things happen that may have affected the whole diagram. See the documentation for DiagramEvent for a complete listing.

When you need to display multiple Models, but not at the same time, you can do so by using only one Diagram and setting the #model to a different one. You can also have two Diagrams share a DIV by swapping the #div to null on one Diagram and setting it on the other. When permanently removing a Diagram,t o clear any memory used, set the #div to null and remove all references to the Diagram. These scenarios are discussed more on the Replacing Diagrams and Models intro page.

Implementers
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Diagram.$1()
factory
Diagram.$2([dynamic init])
factory
Diagram.$3([Object? div, dynamic init])
factory

Properties

allowClipboard bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may copy to or paste parts from the internal clipboard. This allows use of CommandHandler#cutSelection, CommandHandler#copySelection and CommandHandler#pasteSelection. The initial value is true.
getter/setter pair
allowCopy bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may copy objects. The initial value is true.
getter/setter pair
allowDelete bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may delete objects from the Diagram. The initial value is true.
getter/setter pair
allowDragOut bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may start a drag-and-drop in this Diagram, possibly dropping in a different element. The initial value is false.
getter/setter pair
allowDrop bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may end a drag-and-drop operation in this Diagram. This is typically set to true when a Diagram is used with a Palette.
getter/setter pair
allowGroup bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may group parts together. The initial value is true.
getter/setter pair
allowHorizontalScroll bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user is allowed to use the horizontal scrollbar. The initial value is true.
getter/setter pair
allowInsert bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may add parts to the Diagram. The initial value is true.
getter/setter pair

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may draw new links. The initial value is true.
getter/setter pair
allowMove bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may move objects. The initial value is true.
getter/setter pair

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may reconnect existing links. The initial value is true.
getter/setter pair
allowReshape bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may reshape parts. The initial value is true.
getter/setter pair
allowResize bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may resize parts. The initial value is true.
getter/setter pair
allowRotate bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may rotate parts. The initial value is true.
getter/setter pair
allowSelect bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may select objects. The initial value is true.
getter/setter pair
allowTextEdit bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may do in-place text editing. The initial value is true.
getter/setter pair
allowUndo bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may undo or redo any changes. The initial value is true.
getter/setter pair
allowUngroup bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may ungroup existing groups. The initial value is true.
getter/setter pair
allowVerticalScroll bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user is allowed to use the vertical scrollbar. The initial value is true.
getter/setter pair
allowZoom bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may zoom into or out of the Diagram. The initial value is true.
getter/setter pair
animationManager AnimationManager

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the AnimationManager for this Diagram.
getter/setter pair
autoScale EnumValue

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the autoScale behavior of the Diagram, controlling whether or not the Diagram's bounds automatically scale to fit the view.
getter/setter pair
autoScrollInterval num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets number of milliseconds between autoscroll events. The default value is 250.
getter/setter pair
autoScrollRegion Object

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Margin that describes the area along the inside edges of the viewport, in viewport coordinates, where autoscrolling will occur while the mouse (pointer) is held there during dragging or linking or drag-selecting.
getter/setter pair
avoidanceCellSize Size

Available on Diagram, provided by the Diagram$Typings extension

(undocumented)
getter/setter pair
avoidanceLimit num

Available on Diagram, provided by the Diagram$Typings extension

(undocumented)
getter/setter pair
click ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user single-primary-clicks on the background of the Diagram. 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 no object. The function is called in addition to the DiagramEvent that is raised with the name "BackgroundSingleClicked".
getter/setter pair
commandHandler CommandHandler

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the CommandHandler for this Diagram.
getter/setter pair
contentAlignment Spot

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the content alignment Spot of this Diagram, to be used in determining how parts are positioned when the #viewportBounds width or height is larger than the #documentBounds.
getter/setter pair
contextClick ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user single-secondary-clicks on the background of the Diagram. 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 no object. The function is called in addition to the DiagramEvent that is raised with the name "BackgroundContextClicked".
getter/setter pair
contextMenu ↔ dynamic

Available on Diagram, provided by the Diagram$Typings extension

This Adornment or HTMLInfo is shown when the use context clicks in the background. The default value is null, which means no context menu is shown. On touch devices, a special default context menu will appear even there is no context menu defined. See ContextMenuTool#defaultTouchContextMenu for details.
getter/setter pair
currentCursor String

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the current cursor for the Diagram, overriding the #defaultCursor.
getter/setter pair
currentTool Tool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the current tool for this Diagram that handles all input events. This value is frequently replaced by the #toolManager as different tools run.
getter/setter pair
defaultCursor String

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the cursor to be used for the Diagram when no GraphObject specifies a different cursor.
getter/setter pair
defaultScale num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Diagram#scale set by CommandHandler#resetZoom and when computing stretch values, such as when #autoScale or #initialAutoScale are set, or when #zoomToFit is called.
getter/setter pair
defaultTool Tool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default tool for this Diagram that becomes the current tool when the current tool stops. Initially this value is the same tool as #toolManager, which is an instance of ToolManager.
getter/setter pair
delaysLayout bool

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) When set to true Diagram layouts will not get invalidated. Used by some tools stop real-time layouts from occuring during their operation.
getter/setter pair
div HTMLDivElement?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Diagram's HTMLDivElement, via an HTML Element ID. This is typically set automatically when a Div is supplied as an argument to Diagram's constructor.
getter/setter pair
documentBounds Rect

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the bounds of the diagram's contents, in document coordinates.
getter/setter pair
doubleClick ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user double-primary-clicks on the background of the Diagram. 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 no object. The function is called in addition to the DiagramEvent that is raised with the name "BackgroundDoubleClicked".
getter/setter pair
firstInput InputEvent

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the most recent mouse-down InputEvent that occurred.
getter/setter pair
fixedBounds Rect

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a fixed bounding rectangle to be returned by #documentBounds and #computeBounds. By default this has NaN values, meaning that #computeBounds will compute the union of all of the parts in the Diagram to determine the #documentBounds. If all x/y/width/height values are real numbers, this value is used as the #documentBounds.
getter/setter pair
grid Panel

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a Panel of type Panel.Grid acting as the background grid extending across the whole viewport of this diagram.
getter/setter pair
groupSelectionAdornmentTemplate Adornment

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default selection Adornment template, used to adorn selected Groups.
getter/setter pair
groupTemplate Group

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default Group template used as the archetype for group data that is added to the #model.
getter/setter pair
groupTemplateMap Map<String, Group>

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a Map mapping template names to Groups. These groups are copied for each group data that is added to the #model.
getter/setter pair
handlesDragDropForTopLevelParts bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether drag-and-drop events may be bubbled up to the diagram if not handled by a part. The default value is false -- each Node or Link that in the diagram needs to define its own GraphObject#mouseDragEnter, GraphObject#mouseDragLeave, and GraphObject#mouseDrop event handlers if you want dragging/dropping on a part to act as if the user were acting on the diagram.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasHorizontalScrollbar bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the Diagram has a horizontal Scrollbar.
getter/setter pair
hasVerticalScrollbar bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the Diagram has a vertical Scrollbar.
getter/setter pair
highlighteds Set<Part>

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the read-only collection of highlighted parts.
getter/setter pair
initialAutoScale EnumValue

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets how the scale of the diagram is automatically set at the time of the "InitialLayoutCompleted" DiagramEvent, after the model has been replaced.
getter/setter pair
initialContentAlignment Spot

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the initial content alignment Spot of this Diagram, to be used in determining how parts are positioned initially relative to the viewport, when the #viewportBounds width or height is larger than the #documentBounds.
getter/setter pair
initialDocumentSpot Spot

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the spot in the document's area that should be coincident with the #initialViewportSpot of the viewport when the document is first initialized. The default value is Spot.TopLeft.
getter/setter pair
initialPosition Point

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the initial coordinates of this Diagram in the viewport, eventually setting the #position. This value is relevant on initialization of a #model or if #delayInitialization is called. Value must be of type Point in document coordinates. The default is Point(NaN, NaN).
getter/setter pair
initialScale num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the initial scale of this Diagram in the viewport, eventually setting the #scale. This value is relevant on initialization of a #model or if #delayInitialization is called. The default is NaN.
getter/setter pair
initialViewportSpot Spot

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the spot in the viewport that should be coincident with the #initialDocumentSpot of the document when the document is first initialized. The default value is Spot.TopLeft.
getter/setter pair
isEnabled bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the user may interact with the Diagram.
getter/setter pair
isModelReadOnly bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the Diagram's Diagram#model is Model#isReadOnly.
getter/setter pair
isModified bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether this Diagram's state has been modified. Setting this property does not notify about any changed event, but it does raise the "Modified" DiagramEvent, although perhaps not immediately.
getter/setter pair
isMouseCaptured bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether mouse events initiated within the Diagram will be captured. The initial value is true. Setting this property does not notify about any changed event.
getter/setter pair
isReadOnly bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the Diagram may be modified by the user, while still allowing the user to scroll, zoom, and select. The initial value is false.
getter/setter pair
isTreePathToChildren bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the Diagram tree structure is defined by links going from the parent node to their children, or vice-versa. By default this property is true: links go from the parent node to the child node.
getter/setter pair
isVirtualized bool

Available on Diagram, provided by the Diagram$Typings extension

(undocumented)
getter/setter pair
lastInput InputEvent

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the last InputEvent that occurred.
getter/setter pair
layers Iterator<Layer>

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns an iterator for this Diagram's Layers.
getter/setter pair
layout Layout

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Layout used to position all of the top-level nodes and links in this Diagram. By default this property is an instance of a simple Layout that assigns positions to all parts that need it. The value cannot be null and must not be shared with other Diagrams.
getter/setter pair

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns an iterator of all Links in the Diagram.
getter/setter pair
linkSelectionAdornmentTemplate Adornment

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default selection Adornment template, used to adorn selected Links.
getter/setter pair
linkTemplate Link

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default Link template used as the archetype for link data that is added to the #model.
getter/setter pair
linkTemplateMap Map<String, Link>

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a Map mapping template names to Links. These links are copied for each link data that is added to the #model.
getter/setter pair
maxScale num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the largest value that #scale may take. This property is only used to limit the range of new values of #scale.
getter/setter pair
maxSelectionCount num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the maximum number of selected objects. The default value is a large positive integer. Values must be non-negative. Decreasing this value may cause objects to be removed from #selection in order to meet the new lower limit.
getter/setter pair
minScale num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the smallest value greater than zero that #scale may take. This property is only used to limit the range of new values of #scale.
getter/setter pair
model Model

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Model holding data corresponding to the data-bound nodes and links of this Diagram.
getter/setter pair
mouseDragOver ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user is dragging the selection in the background of the Diagram during a DraggingTool drag-and-drop, not over any GraphObjects.
getter/setter pair
mouseDrop ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user drops the selection in the background of the Diagram at the end of a DraggingTool drag-and-drop, not onto any GraphObjects.
getter/setter pair
mouseEnter ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the mouse (pointer) enters the Diagram. (When the browser's mouseEnter event fires on the Diagram canvas.)
getter/setter pair
mouseHold ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user holds the mouse (pointer) stationary in the background of the Diagram while holding down a button, not over any GraphObjects. This property is used by the ToolManager.
getter/setter pair
mouseHover ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user holds the mouse (pointer) stationary in the background of the Diagram without holding down any buttons, not over any GraphObjects. This property is used by the ToolManager.
getter/setter pair
mouseLeave ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the mouse (pointer) leaves the Diagram.
getter/setter pair
mouseOver ↔ void Function(InputEvent)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function to execute when the user moves the mouse (pointer) in the background of the Diagram without holding down any buttons, not over any GraphObjects. This property is used by the ToolManager.
getter/setter pair
nodes Iterator<Node>

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns an iterator of all Nodes and Groups in the Diagram.
getter/setter pair
nodeSelectionAdornmentTemplate Adornment

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default selection Adornment template, used to adorn selected Parts other than Groups or Links.
getter/setter pair
nodeTemplate Part

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the default Node template used as the archetype for node data that is added to the #model. Setting this property just modifies the #nodeTemplateMap by replacing the entry named with the empty string.
getter/setter pair
nodeTemplateMap Map<String, Part>

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a Map mapping template names to Parts. These nodes are copied for each node data that is added to the #model.
getter/setter pair
opacity num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the opacity for all parts in this diagram. The value must be between 0.0 (fully transparent) and 1.0 (no additional transparency). This value is multiplicative with any existing transparency, for instance from a Brush or image transparency. The default value is 1.
getter/setter pair
padding Object

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the Margin that describes the Diagram's padding, which controls how much extra space in document coordinates there is around the area occupied by the document. This keeps nodes from butting up against the side of the diagram (unless scrolled).
getter/setter pair
parts Iterator<Part>

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns an iterator of all Parts in the Diagram that are not Nodes or Links or Adornments.
getter/setter pair
position Point

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the coordinates of this Diagram in the viewport. Value must be of type Point in document coordinates. The default is Point(NaN, NaN), but is typically set to a real value when a Diagram is initialized.
getter/setter pair
positionComputation Point Function(Diagram, Point)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function used to determine the position that this Diagram can be scrolled or moved to.
getter/setter pair
renderer Renderer

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the rendering context type. Values are 'default', which uses the HTML Canvas, or 'svg', which builds and updates an SVG DOM.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the scale transform of this Diagram. Value must be a positive number. The default value is 1. Any new value will be coerced to be between #minScale and #maxScale.
getter/setter pair
scaleComputation num Function(Diagram, num)?

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the function used to determine valid scale values for this Diagram.
getter/setter pair
scrollHorizontalLineChange num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the distance in screen pixels that the horizontal scrollbar will scroll when scrolling by a line.
getter/setter pair
scrollMargin Object

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a scrollable area in document coordinates that surrounds the document bounds, allowing the user to scroll into empty space.
getter/setter pair
scrollMode EnumValue

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the scrollMode of the Diagram, allowing the user to either scroll to document bound borders with Diagram.DocumentScroll, or scroll endlessly with Diagram.InfiniteScroll.
getter/setter pair
scrollsPageOnFocus bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether the page may be scrolled when the diagram receives focus. This happens in some browsers when the top-left corner of the diagram's HTMLDivElement is scrolled out of view, the diagram does not have focus, and the user clicks in the diagram.
getter/setter pair
scrollVerticalLineChange num

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the distance in screen pixels that the vertical scrollbar will scroll when scrolling by a line.
getter/setter pair
selection Set<Part>

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the read-only collection of selected objects. Most commands and many tools operate on this collection.
getter/setter pair
skipsUndoManager bool

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets whether ChangedEvents are not recorded by the UndoManager. The initial and normal value is false. WARNING: while this property is true do not perform any changes that cause any previous transactions to become impossible to undo.
getter/setter pair
toolManager ToolManager

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the ToolManager for this Diagram. This tool is used for mode-less operation. It is responsible for choosing a particular tool to run as the #currentTool.
getter/setter pair
toolTip ↔ dynamic

Available on Diagram, provided by the Diagram$Typings extension

This Adornment or HTMLInfo is shown when the mouse (pointer) stays motionless in the background. The default value is null, which means no tooltip is shown.
getter/setter pair
undoManager UndoManager

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the UndoManager for this Diagram, which actually belongs to the #model.
getter/setter pair
validCycle EnumValue

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets what kinds of graphs this diagram allows the user to draw. By default this property is Diagram.CycleAll -- all kinds of cycles are permitted. Common values include Diagram.CycleDestinationTree and Diagram.CycleNotDirected.
getter/setter pair
viewportBounds Rect

Available on Diagram, provided by the Diagram$Typings extension

This read-only property returns the bounds of the portion of the Diagram in document coordinates that is viewable from its HTML Canvas. Typically when the viewport bounds are smaller than the #documentBounds, the user can scroll or pan the view.
getter/setter pair
viewSize Size

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets a fixed size in document coordinates to be returned by #viewportBounds. This is typically only set when the Diagram's #div is null. This property is intended to be used in DOM-less environments where there is no Diagram #div expected, to simulate the size of the DIV. Normally, the #viewportBounds is sized by the DIV instead.
getter/setter pair
zoomPoint Point

Available on Diagram, provided by the Diagram$Typings extension

Gets or sets the zoom point of this Diagram, in viewport coordinates. This is used by Tool#standardMouseWheel and scale-setting commands to control where to zoom in or out.
getter/setter pair

Methods

add(Part part) → void

Available on Diagram, provided by the Diagram$Typings extension

Adds a Part to the Layer that matches the Part's Part#layerName, or else the default layer, which is named with the empty string.
addChangedListener(void listener(ChangedEvent)) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Register an event handler that is called when there is a ChangedEvent because this Diagram or one of its Parts has changed, but not because the Model or any model data has changed.
addDiagramListener(DiagramEventName name, void listener(DiagramEvent)) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Register an event handler that is called when there is a DiagramEvent of a given name.
addEventListener(EventTarget domElement, String name, bool capture, [dynamic listener]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented), but may be useful for change detection calls in Angular. @expose
addLayer(Layer layer) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Adds a new Layer to the list of layers. If Layer#isTemporary is false, the layer is added after all existing non-temporary layers. If Layer#isTemporary is true, the layer is added as the very last layer. @param {Layer} layer The new Layer to add. It is an error if the Layer already belongs to a Diagram. @see #addLayerBefore @see #addLayerAfter @see #removeLayer @see #findLayer @return {Diagram} this Diagram
addLayerAfter(Layer layer, Layer existingLayer) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Adds a layer to the list of layers after a specified layer. This method can also re-order layers. @param {Layer} layer the new Layer to add or existing Layer to move in Z-order. @param {Layer} existingLayer the other Layer in this Diagram which should come just before the new or moved layer. @see #addLayer @see #addLayerBefore @see #removeLayer @return {Diagram} this Diagram
addLayerBefore(Layer layer, Layer existingLayer) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Adds a layer to the list of layers before a specified layer. This method can also re-order layers. @param {Layer} layer the new Layer to add or existing Layer to move in Z-order. @param {Layer} existingLayer the other Layer in this Diagram which should come just after the new or moved layer. @see #addLayer @see #addLayerAfter @see #removeLayer @return {Diagram} this Diagram
addModelChangedListener(void listener(ChangedEvent)) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Register an event handler on this Diagram's Diagram#model that is called when there is a ChangedEvent on the Model, not in this diagram. Be sure to call #removeModelChangedListener when you are done with the diagram.
addRenderer(String name, ISurface surface) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Add a renderer to the Diagram. This property is only used when building GoJS from source.
alignDocument(Spot documentspot, Spot viewportspot) → void

Available on Diagram, provided by the Diagram$Typings extension

Aligns the Diagram's #position based on a desired document Spot and viewport Spot. @param {Spot} documentspot @param {Spot} viewportspot
attach(Object props) Diagram

Available on Diagram, provided by the Diagram$Typings extension

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

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Start or stop caching Group.findExternalLinksConnected
centerRect(Rect r) → void

Available on Diagram, provided by the Diagram$Typings extension

Modifies the #position to show a given Rect of the Diagram by centering the viewport on that Rect.
clear() → void

Available on Diagram, provided by the Diagram$Typings extension

Removes all Parts from the Diagram, including unbound Parts except for the background grid, and also clears out the Model and UndoManager and clipboard. This operation is not undoable.
clearHighlighteds() → void

Available on Diagram, provided by the Diagram$Typings extension

Remove highlights from all Parts. This removes all parts from the #highlighteds collection.
clearSelection([bool? skipsEvents]) → void

Available on Diagram, provided by the Diagram$Typings extension

Deselect all selected Parts. This removes all parts from the #selection collection.
commit(void func(Diagram), [String? tname]) → void

Available on Diagram, provided by the Diagram$Typings extension

Starts a new transaction, calls the provided function, and commits the transaction. Code is called within a try-finally statement. If the function does not return normally, this rolls back the transaction rather than committing it. Example usage:
commitTransaction([String? tname]) bool

Available on Diagram, provided by the Diagram$Typings extension

Commit the changes of the current transaction. This just calls UndoManager#commitTransaction. @param {string=} tname a descriptive name for the transaction. @return {boolean} the value returned by UndoManager#commitTransaction.
computeAutoScrollPosition(Point viewPnt) Point

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) @expose @param {Point} viewPnt in viewport coordinates @return {Point} in document coordinates
computeBounds([Rect? rect]) Rect

Available on Diagram, provided by the Diagram$Typings extension

This is called during a Diagram update to determine a new value for #documentBounds. By default this computes the union of the bounds of all the visible GraphObjects in this Diagram, unless Diagram#fixedBounds is set. This ignores parts for which Part#isVisible is false and ignores those for which Part#isInDocumentBounds is false. The returned value includes the addition of the #padding margin.
computeMove(Part n, Point newloc, DraggingOptions dragOptions, [Point? result]) Point

Available on Diagram, provided by the Diagram$Typings extension

This method computes the new location for a Node or simple Part, given a new desired location, taking any grid-snapping into consideration, any Part#dragComputation function, and any Part#minLocation and Part#maxLocation.
computePartsBounds(Object coll, [bool? includeLinks]) Rect

Available on Diagram, provided by the Diagram$Typings extension

Find the union of the GraphObject#actualBounds of all of the Parts in the given collection, excluding Links unless the second argument is true.
computePixelRatio() num

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Computes the device pixel ratio divided by the backing store pixel ratio Used to set this._pixelRatio to a value other than 1. @expose @return {number}
copyParts(Object coll, [Diagram? diagram, bool? check]) Map<Part, Part>

Available on Diagram, provided by the Diagram$Typings extension

Make a copy of a collection of Parts and return them in a Map mapping each original Part to its copy. It may optionally add them to a given Diagram. Copying a Group will also copy its member Nodes and Links. Copying a Link will also copy any label Nodes that it owns.
delayInitialization([void func([Diagram?])?]) → void

Available on Diagram, provided by the Diagram$Typings extension

Updates the diagram immediately, then resets initialization flags so that actions taken in the argument function will be considered part of Diagram initialization, and will participate in initial layouts, #initialAutoScale, #initialContentAlignment, etc.
doAutoScroll(Point viewPt) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Called by DraggingTool and LinkingTool to implement auto-scrolling. @param {Point} viewPt
doFocus() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Focus the Diagram's canvas, allowing it to receive keyboard events. This is called upon activation of mouseDown or mouseMove tools, or on any mouseUp.
ensureBounds() → void

Available on Diagram, provided by the Diagram$Typings extension

Ensures that the #documentBounds are up to date. This is sometimes necessary when operations need updated document bounds immediately.
findLayer(String name) Layer?

Available on Diagram, provided by the Diagram$Typings extension

Finds a layer with a given name. @param {string} name @return {Layer} a Layer with the given name, or null if no such layer was found. @see #addLayerBefore @see #addLayerAfter @see #removeLayer
findLinkForData(Object linkdata) Link?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Link corresponding to a GraphLinksModel's link data object. @param {Object} linkdata a JavaScript object matched by reference identity; use #findLinksByExample if you want to find those Links whose data matches an example data object @return {Link} an existing Link in this Diagram that was created because its Part.data was the link data in the Diagram's Model.
findLinkForKey(dynamic key) Link?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Link corresponding to a model's link data object's unique key. @param {(string|number|undefined)} key a string or number. @return {Link} null if a link data with that key cannot be found in the model, or if a corresponding Link cannot be found in the Diagram, or if the model is a GraphLinksModel without GraphLinksModel#linkKeyProperty set to a non-empty string. @since 2.1
findLinksByExample([Iterable? examples]) Iterator<Link>

Available on Diagram, provided by the Diagram$Typings extension

Search for Links by matching the Link data with example data holding values, RegExps, or predicates.
findNodeForData(Object nodedata) Node?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Node or Group corresponding to a model's node data object. @param {Object} nodedata a JavaScript object matched by reference identity; use #findNodesByExample if you want to find those Nodes whose data matches an example data object @return {Node} an existing Node or Group in this Diagram that was created because its Part.data was the node data in the Diagram's Model. This will be null if there is no such part or if it's just a Part or Link.
findNodeForKey(dynamic key) Node?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Node or Group corresponding to a model's node data object's unique key. @param {(string|number|undefined)} key a string or number. @return {Node} null if a node data with that key cannot be found in the model, or if a corresponding Node or Group cannot be found in the Diagram, or if what is found is just a Part.
findNodesByExample([Iterable? examples]) Iterator<Node>

Available on Diagram, provided by the Diagram$Typings extension

Search for Nodes or Groups by matching the Node data with example data holding values, RegExps, or predicates.
findObjectAt<T extends GraphObject>(Point p, [T? navig(GraphObject)?, bool pred(T)?]) → T?

Available on Diagram, provided by the Diagram$Typings extension

Find the front-most GraphObject at the given point in document coordinates.
findObjectsAt<T extends GraphObject, S extends Iterable<T>>(Point p, [T? navig(GraphObject)?, bool pred(T)?, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

Return a collection of the GraphObjects at the given point in document coordinates.
findObjectsIn<T extends GraphObject, S extends Iterable<T>>(Rect r, [T? navig(GraphObject)?, bool pred(T)?, bool? partialInclusion, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

Returns a collection of all GraphObjects that are inside or that intersect a given Rect in document coordinates.
findObjectsNear<T extends GraphObject, S extends Iterable<T>>(Point p, num dist, [T? navig(GraphObject)?, bool pred(T)?, Object? partialInclusion, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

Returns a collection of all GraphObjects that are within a certain distance of a given point in document coordinates.
findPartAt(Point p, [bool? selectable]) Part?

Available on Diagram, provided by the Diagram$Typings extension

This convenience function finds the front-most Part that is at a given point that might be selectable and that is not in a temporary layer.
findPartForData(Object data) Part?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Part, Node, Group, or Link corresponding to a Model's data object. We recommend that you call #findNodeForData or #findLinkForData if you are looking for a Node or a Link. @param {Object} data a JavaScript object matched by reference identity @return {Part} an existing Part in this Diagram that was created because its Part.data was the data in the Diagram's Model.
findPartForKey(dynamic key) Part?

Available on Diagram, provided by the Diagram$Typings extension

Look for a Part or Node or Group corresponding to a model's data object's unique key. This will find a Link if the model is a GraphLinksModel that is maintaining a key on the link data objects. @param {(string|number|undefined)} key a string or number. @return {Part} null if a data with that key cannot be found in the model, or if a corresponding Part cannot be found in the Diagram. This will not return a Link unless the model is a GraphLinksModel and GraphLinksModel#linkKeyProperty has been set. If the same key is used for both a node data object and a link data object, this will return a Node.
findPartsAt<T extends Part, S extends Iterable<T>>(Point p, [bool? selectable, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

This convenience function finds all Parts that are at a point in document coordinates and that are not in temporary layers.
findPartsIn<T extends Part, S extends Iterable<T>>(Rect r, [bool? partialInclusion, bool? selectable, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

This convenience function finds Parts that are inside or that intersect a given Rect in document coordinates.
findPartsNear<T extends Part, S extends Iterable<T>>(Point p, num dist, [bool? partialInclusion, bool? selectable, S? coll]) → S

Available on Diagram, provided by the Diagram$Typings extension

This convenience function finds Parts that are within a certain distance of a given point in document coordinates.
findTopLevelGroups() Iterator<Group>

Available on Diagram, provided by the Diagram$Typings extension

Returns an iterator of all Groups that are at top-level, in other words that are not themselves inside other Groups.
findTreeRoots() Iterator<Node>

Available on Diagram, provided by the Diagram$Typings extension

Returns an iterator of all top-level Nodes that have no tree parents.
focus() → void

Available on Diagram, provided by the Diagram$Typings extension

Explicitly bring HTML focus to the Diagram's canvas. This is called by tools that may create other HTML elements such as TextEditingTool.
focusObject([GraphObject? obj]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Sets the GraphObject on which to focus the viewport. @param {GraphObject | null} obj @since 2.1
getInputOption(String name) → dynamic

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Get value of a given input option @param {string} name @return {*}
getRenderingHint(String name) → dynamic

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Get value of a given rendering hint. @param {string} name @return {*}
highlight([Part? part]) → void

Available on Diagram, provided by the Diagram$Typings extension

Make the given part the only highlighted part. Afterwards the #highlighteds collection will have only the given part in it.
highlightCollection(Object coll) → void

Available on Diagram, provided by the Diagram$Typings extension

Highlight all of the Parts supplied in the given collection, and unhighlight all other highlighted Parts.
invalidateDocumentBounds() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Requests that the Diagram updates its #documentBounds in the near-future.
layoutDiagram([bool? invalidateAll]) → void

Available on Diagram, provided by the Diagram$Typings extension

Perform all invalid layouts. If the optional argument is true, this will perform all of the layouts (Diagram#layout and all Group#layouts), not just the invalid ones.
makeImage([ImageRendererOptions? options]) HTMLImageElement?

Available on Diagram, provided by the Diagram$Typings extension

Create an HTMLImageElement that contains a bitmap of the current Diagram. This method is just a convenience function that creates an image, sets its source to the returned string of #makeImageData, and returns a reference to that Image.
makeImageData([ImageRendererOptions? options]) → dynamic

Available on Diagram, provided by the Diagram$Typings extension

Create a bitmap of the current Diagram encoded as a base64 string, or returned as an ImageData object. This method uses the toDataURL method of the HTMLCanvasElement to create the data URL, or the getImageData method of the Canvas Context. Unlike toDataURL, this method will not throw an error if cross-domain images were drawn on the canvas, instead it will return a data URL of a bitmap with those images omitted.
makeSvg([SvgRendererOptions? options]) SVGElement?

Available on Diagram, provided by the Diagram$Typings extension

Create an SVGElement that contains a SVG rendering of the current Diagram.
maybeUpdate() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) The use of this method at the wrong time may have some unexpected side-effects.
moveParts(Object coll, Point offset, [bool? check, DraggingOptions? dragOptions]) → void

Available on Diagram, provided by the Diagram$Typings extension

Move a collection of Parts in this Diagram by a given offset. Moving a Group will also move its member Nodes and Links. Moving with a zero X and a zero Y offset is potentially useful in order to snap Parts to the grid if DraggingTool#isGridSnapEnabled is true.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
raiseDiagramEvent(DiagramEventName name, [Object? obj, dynamic param]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Notify any DiagramEvent listeners by calling all event handlers registered by #addDiagramListener. @param {string} name the name is normally capitalized, but this method uses case-insensitive comparison. @param {Object=} obj an optional subject of the event. @param {*=} param an optional parameter describing the change to the subject of the event. @see #addDiagramListener @see #removeDiagramListener
rebuildParts() → void

Available on Diagram, provided by the Diagram$Typings extension

Remove all of the Parts created from model data and then create them again. This must be called after modifying or replacing any of the template maps such as #nodeTemplateMap. This re-selects all of the new Parts that were created from data of the original selected Parts.
redraw() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Invalidates all non-layout diagram state and forces an immediate redraw. Because this can be very inefficient, to discourage its use it remains an undocumented part of the API. @expose
remove(Part part) → void

Available on Diagram, provided by the Diagram$Typings extension

Removes a Part from its Layer, provided the Layer is in this Diagram. Removing a Node will also remove any Links that are connected with it. Removing a Group will also remove all of its members. Removing a Link will also remove all of its label Nodes, if it has any. @param {Part} part @see #add
removeChangedListener(void listener(ChangedEvent)) → void

Available on Diagram, provided by the Diagram$Typings extension

Unregister a ChangedEvent handler. The function argument must be the same reference as was passed to #addChangedListener. @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument. @see #addChangedListener
removeDiagramListener(DiagramEventName name, void listener(DiagramEvent)) → void

Available on Diagram, provided by the Diagram$Typings extension

Unregister a DiagramEvent handler.
removeEventListener(EventTarget domElement, String name, bool capture, [dynamic listener]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented), but may be useful for change detection calls in Angular. @expose
removeLayer(Layer layer) → void

Available on Diagram, provided by the Diagram$Typings extension

Removes the given layer from the list of layers.
removeModelChangedListener(void listener(ChangedEvent)) → void

Available on Diagram, provided by the Diagram$Typings extension

Unregister a ChangedEvent handler from this Diagram's Diagram#model. The function argument must be the same reference as was passed to #addChangedListener. @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument. @see #addModelChangedListener @since 1.6
removeParts(Object coll, [bool? check]) → void

Available on Diagram, provided by the Diagram$Typings extension

This method removes from this Diagram all of the Parts in a collection. Removing a Node will also remove any Links that are connected with it. Removing a Group will also remove all of its members. Removing a Link will also remove all of its label Nodes, if it has any.
requestUpdate([bool? alwaysQueueUpdate]) → void

Available on Diagram, provided by the Diagram$Typings extension

Usage of this method is uncommon and may affect performance, for efficiency do not call this method unless you have a well-defined need. Normally, GoJS updates the diagram automatically, and completeing a transaction ensures an immediate update.
reset() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Call #clear and also restore the templates, layers, layout and various Diagram properties to their original state. @expose
rollbackTransaction() bool

Available on Diagram, provided by the Diagram$Typings extension

Rollback the current transaction, undoing any recorded changes. This just calls UndoManager#rollbackTransaction. @return {boolean} the value returned by UndoManager#rollbackTransaction.
scroll(Scroll unit, ScrollOptions dir, [num? dist]) → void

Available on Diagram, provided by the Diagram$Typings extension

Scrolling function used by primarily by #commandHandler's CommandHandler#doKeyDown. @param {string} unit A string representing the unit of the scroll operation. Can only be 'pixel', 'line', 'page', or 'document'. @param {string} dir The direction of the scroll operation. Can only be 'up', 'down', 'left', or 'right'. @param {number=} dist An optional distance multiplier, for multiple pixels, lines, or pages. The default value is 1. This argument is ignored when the unit is 'document'. @see #scrollToRect @see #centerRect
scrollToRect(Rect r) → void

Available on Diagram, provided by the Diagram$Typings extension

Modifies the #position to show a given Rect of the Diagram by centering the viewport on that Rect. Does nothing if the Rect is already entirely in view.
select([Part? part]) → void

Available on Diagram, provided by the Diagram$Typings extension

Make the given object the only selected object. Afterwards the #selection collection will have only the given part in it.
selectCollection(Object coll) → void

Available on Diagram, provided by the Diagram$Typings extension

Select all of the Parts supplied in the given collection, and deselect all other Parts.
set(dynamic config) Diagram

Available on Diagram, provided by the Diagram$Typings extension

Set any number of properties on this Diagram. 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 sub-objects such as the Diagram#toolManager, Diagram#animationManager, or Diagram#commandHandler, use Diagram#attach.
setInputOption(String name, [dynamic val]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Set value of a given input option @param {string} name @param {*} val
setProperties(Object props) Diagram

Available on Diagram, provided by the Diagram$Typings extension

This method sets a collection of properties according to the property/value pairs that have been set on the given Object, in the same manner as GraphObject.make does when constructing a Diagram with an argument that is a simple JavaScript Object.
setRenderingHint(String name, [dynamic val]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Set a rendering hint and draw immediately. @param {string} name @param {*} val
setRTL([HTMLElement? elem]) → void

Available on Diagram, provided by the Diagram$Typings extension

@expose (undocumented) Used in Diagram constructor setup, this computes the pixel width of the scrollbars @param {HTMLElement=} elem
setScrollWidth([HTMLElement? elem]) → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Computes the pixel width of the scrollbars @expose @param {HTMLElement=} elem
startTransaction([String? tname]) bool

Available on Diagram, provided by the Diagram$Typings extension

Begin a transaction, where the changes are held by a Transaction object in the UndoManager. This just calls UndoManager#startTransaction. @param {string=} tname a descriptive name for the transaction. @return {boolean} the value returned by UndoManager#startTransaction. @see #commit
stopAutoScroll() → void

Available on Diagram, provided by the Diagram$Typings extension

(undocumented) Stop any ongoing auto-scroll action.
toString() String
A string representation of this object.
inherited
transformDocToView(Point p) Point

Available on Diagram, provided by the Diagram$Typings extension

Given a Point in document coordinates, return a new Point in viewport coordinates. @param {Point} p @return {Point} The given Point converted into View coordinates. @see #transformViewToDoc @see GraphObject#getDocumentPoint
transformViewToDoc(Point p) Point

Available on Diagram, provided by the Diagram$Typings extension

Given a point in viewport coordinates, return a new Point in document coordinates. @param {Point} p @return {Point} The given point converted into Document coordinates. @see #transformDocToView @see GraphObject#getDocumentPoint
updateAllRelationshipsFromData() → void

Available on Diagram, provided by the Diagram$Typings extension

Add or remove any nodes or links according to additional or missing data objects in the model and update all of the references to nodes, in case they had been modified in the model without properly notifying the model by calling Model#addNodeData or GraphLinksModel#removeLinkData or GraphLinksModel#setGroupKeyForNodeData or GraphLinksModel#setToKeyForLinkData or other similar methods. This method does not conduct a transaction, so you need to start and commit one yourself.
updateAllTargetBindings([String? srcprop]) → void

Available on Diagram, provided by the Diagram$Typings extension

Update all of the data-bound properties of Nodes and Links in this diagram, without having to call Model#setDataProperty. This copies/converts model data properties to set properties on Parts. This method does not conduct a transaction, so you need to start and commit one yourself.
zoomToFit() → void

Available on Diagram, provided by the Diagram$Typings extension

Scales the Diagram to uniformly fit into the viewport. To have this done automatically, set the Diagram's #autoScale to Diagram.Uniform.
zoomToRect(Rect r, [EnumValue? scaling]) → void

Available on Diagram, provided by the Diagram$Typings extension

Modifies the #scale and #position of the Diagram so that the viewport displays a given document-coordinates rectangle. @param {Rect} r rectangular bounds in document coordinates. @param {EnumValue=} scaling an optional value of either Diagram.Uniform (the default) or Diagram.UniformToFill. @since 1.1

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

cycleAll EnumValue
This value for Diagram#validCycle states that there are no restrictions on making cycles of links.
getter/setter pair
cycleDestinationTree EnumValue
This value for Diagram#validCycle states that any number of destination links may go out of a node, but at most one source link may come into a node, and there are no directed cycles.
getter/setter pair
cycleNotDirected EnumValue
This value for Diagram#validCycle states that a valid link from a node will not produce a directed cycle in the graph.
getter/setter pair
cycleNotUndirected EnumValue
This value for Diagram#validCycle states that a valid link from a node will not produce an undirected cycle in the graph.
getter/setter pair
cycleSourceTree EnumValue
This value for Diagram#validCycle states that any number of source links may come into a node, but at most one destination link may go out of a node, and there are no directed cycles.
getter/setter pair
documentScroll EnumValue
This value for Diagram#scrollMode states that the viewport constrains scrolling to the Diagram document bounds.
getter/setter pair
infiniteScroll EnumValue
This value for Diagram#scrollMode states that the viewport does not constrain scrolling to the Diagram document bounds.
getter/setter pair
licenseKey String
Gets or sets the license key.
getter/setter pair
none EnumValue
The default autoScale type, used as the value of Diagram#autoScale: The Diagram does not attempt to scale so that its documentBounds would fit the view.
getter/setter pair
uniform EnumValue
Diagrams with this autoScale type, used as the value of Diagram#autoScale, are scaled uniformly until the whole documentBounds fits in the view.
getter/setter pair
uniformToFill EnumValue
Diagrams with this autoScale type, used as the value of Diagram#autoScale, are scaled until the documentBounds fits in the view in one direction while a scrollbar is still needed in the other direction.
getter/setter pair
version String
Gets the current GoJS version.
getter/setter pair

Static Methods

fromDiv(Object div) Diagram?
This static function gets the Diagram that is attached to an HTML DIV element.
inherit(Function derivedclass, Function baseclass) → void
This static function declares that a class (constructor function) derives from another class -- but please note that most classes do not support inheritance. Do not call this function when your class is defined using an ES2015 or TypeScript "class" declaration.
isUsingDOM() bool
This static function returns true if GoJS detects a DOM. In browser environments this is expected to be true, in Node-like environments, false. Specifically, this will be false if there is no root document in the JavaScript context, or if the DOM was disabled explicitly by calling Diagram.useDOM.
useDOM(bool value) → void
This static function sets whether or not GoJS should use a DOM, if one exists. This can be set to false to simulate a DOM-less environment. It is uncommon to set this, but may be required in some testing environments.