Extends EventSource to implement a graph component for the browser. This is the main class of the package.

To activate panning and connections use setPanning and setConnectable. For rubberband selection you must create a new instance of rubberband.

The following listeners are added to mouseListeners by default:

These listeners will be called in the above order if they are enabled.

Hierarchy (view full)

Constructors

Properties

addAllEdges addCell addCellOverlay addCells addEdge addImageBundle addMouseListener addSelectionCell addSelectionCells alignCells allowAutoPanning allowDanglingEdges allowLoops allowNegativeCoordinates alreadyConnectedResource alternateEdgeStyle autoExtend autoScroll autoSizeCell autoSizeCells autoSizeCellsOnAdd backgroundImage border canExportCell canImportCell cellConnected cellLabelChanged cellRenderer cellResized cells cellsAdded cellsBendable cellsCloneable cellsDeletable cellsDisconnectable cellsEditable cellsFolded cellSizeUpdated cellsLocked cellsMovable cellsMoved cellsOrdered cellsRemoved cellsResizable cellsResized cellsSelectable cellsToggled centerZoom clearCellOverlays clearSelection click cloneCell cloneCells cloneInvalidEdges collapseExpandResource connectableEdges connectCell constrainChild constrainChildCells constrainChildren constrainRelativeChildren consumeMouseEvent container containsValidationErrorsResource createEdge createGroupCell dblClick defaultLoopStyle defaultOverlap defaultParent destroyed dialect disconnectGraph disconnectOnMove doneResource doubleClickCounter doubleTapEnabled doubleTapTimeout doubleTapTolerance dropEnabled edgeLabelsMovable enabled enterGroup enterStopsCellEditing escape escapeEnabled eventListeners eventsEnabled eventSource exitGroup exportEnabled extendParent extendParents extendParentsOnAdd extendParentsOnMove fireDoubleClick fireGestureEvent fireMouseEvent flipEdge foldCells getActualStartSize getAllConnectionConstraints getAllEdges getBoundingBox getBoundingBoxFromGeometry getBoundsForGroup getCellAt getCellBounds getCellContainmentArea getCellOverlays getCells getCellsBeyond getCellsForGroup getCellsForUngroup getCellStyle getCellValidationError getChildCells getChildEdges getChildVertices getCloneableCells getCollapseExpandResource getConnectionConstraint getConnectionPoint getConnections getCurrentCellStyle getCursorForCell getCursorForMouseEvent getDeletableCells getDropTarget getEdges getEdgesBetween getEdgeValidationError getEditingValue getEventState getEventTolerance getExportableCells getFoldableCells getFoldingImage getGridSize getImageFromBundles getImportableCells getIncomingEdges getLabel getMovableCells getOpposites getOutgoingEdges getOutlineConstraint getPanDx getPanDy getPointForEvent getPreferredSizeForCell getSelectionCell getSelectionCells getSelectionCellsForChanges getSelectionCount getSelectionModel getSnapTolerance getStartSize getStateForTouchEvent getSwimlane getSwimlaneAt getSwimlaneDirection getTerminalForPort getTooltip getTooltipForCell graphModelChangeListener gridEnabled gridSize groupCells hitsSwimlaneContent horizontalPageBreaks htmlLabels ignoreMouseEvents ignoreScrollbars imageBundles importCells importEnabled initialTouchX initialTouchY intersects invokesStopCellEditing isAllowAutoPanning isAllowDanglingEdges isAllowNegativeCoordinates isAutoExtend isAutoScroll isAutoSizeCell isAutoSizeCells isCellBendable isCellCloneable isCellDeletable isCellDisconnectable isCellEditable isCellFoldable isCellLocked isCellMovable isCellResizable isCellRotatable isCellsBendable isCellsCloneable isCellsDeletable isCellsDisconnectable isCellsEditable isCellSelectable isCellSelected isCellsLocked isCellsMovable isCellsResizable isCellsSelectable isCloneEvent isCloneInvalidEdges isConnectable isConnectableEdges isConstrainChild isConstrainChildren isConstrainedEvent isConstrainedMoving isConstrainRelativeChildren isDisconnectOnMove isDropEnabled isEdgeLabelsMovable isEdgeValid isEditing isEnterStopsCellEditing isEscapeEnabled isEventIgnored isEventSourceIgnored isExtendParent isExtendParents isExtendParentsOnAdd isExtendParentsOnMove isFoldingEnabled isGridEnabled isGridEnabledEvent isHtmlLabel isHtmlLabels isIgnoreTerminalEvent isInvokesStopCellEditing isLabelClipped isLabelMovable isLabelsVisible isMouseDown isMouseTrigger isNativeDblClickEnabled isPort isPortsEnabled isResetEdgesOnConnect isResetEdgesOnMove isResetEdgesOnResize isSelectionEmpty isSiblingSelected isSplitEnabled isSplitTarget isSwimlane isSwimlaneNesting isSwimlaneSelectionEnabled isSyntheticEventIgnored isTerminalPointMovable isTimerAutoScroll isToggleEvent isTransparentClickEvent isUseScrollbarsForPanning isValidAncestor isValidConnection isValidDropTarget isValidSource isValidTarget isVertexLabelsMovable isWrapping keepEdgesInBackground keepEdgesInForeground keepSelectionVisibleOnZoom labelChanged labelsVisible lastEvent lastMouseX lastMouseY lastTouchCell lastTouchEvent lastTouchTime lastTouchX lastTouchY maxFitScale maximumContainerSize maximumGraphBounds minFitScale minimumContainerSize minimumGraphSize minPageBreakDist model mouseListeners mouseMoveRedirect mouseUpRedirect moveCells multigraph multiplicities nativeDblClickEnabled options orderCells pageBreakColor pageBreakDashed pageBreaksVisible pageFormat pageScale pageVisible paintBackground panDx panDy panGraph portsEnabled postProcessCellStyle preferPageSize recursiveResize removeCellOverlay removeCellOverlays removeCells removeCellsAfterUngroup removeCellsFromParent removeImageBundle removeMouseListener removeSelectionCell removeSelectionCells removeStateForCell renderHint resetEdge resetEdges resetEdgesOnConnect resetEdgesOnMove resetEdgesOnResize resetViewOnRootChange resizeCell resizeCells resizeChildCells resizeContainer scaleCell scrollCellToVisible scrollRectToVisible selectAll selectCell selectCellForEvent selectCells selectCellsForEvent selectChildCell selectEdges selectionModel selectNextCell selectParentCell selectPreviousCell selectRegion selectVertices setAllowDanglingEdges setAllowNegativeCoordinates setAutoSizeCells setCellsBendable setCellsCloneable setCellsDeletable setCellsDisconnectable setCellsEditable setCellsLocked setCellsMovable setCellsResizable setCellsSelectable setCellStyle setCellStyleFlags setCellStyles setCellWarning setCloneInvalidEdges setConnectable setConnectableEdges setConnectionConstraint setConstrainChildren setConstrainRelativeChildren setDisconnectOnMove setDropEnabled setEdgeLabelsMovable setEnterStopsCellEditing setEscapeEnabled setEventTolerance setExtendParents setExtendParentsOnAdd setExtendParentsOnMove setGridEnabled setGridSize setHtmlLabels setInvokesStopCellEditing setPanDx setPanDy setPanning setPortsEnabled setSelectionCell setSelectionCells setSelectionModel setSplitEnabled setSwimlaneNesting setSwimlaneSelectionEnabled setTooltips setVertexLabelsMovable shiftPreview1 shiftPreview2 singleSelection sizeDidChange snap snapDelta snapTolerance splitEdge splitEnabled startEditing startEditingAtCell stopEditing stylesheet swapBounds swimlaneIndicatorColorAttribute swimlaneNesting swimlaneSelectionEnabled tapAndHold tapAndHoldDelay tapAndHoldEnabled tapAndHoldInProgress tapAndHoldThread tapAndHoldValid timerAutoScroll toggleCells toggleCellStyle toggleCellStyleFlags toggleCellStyles tolerance translateCell translateToScrollPosition ungroupCells updateAlternateBounds updateCellSize updateGroupBounds updateMouseEvent updatePageBreaks updateSelection updatingSelectionResource useScrollbarsForPanning validateCell validateEdge validateGraph validationAlert vertexLabelsMovable verticalPageBreaks view warningImage zoom zoomActual zoomFactor zoomIn zoomOut zoomTo zoomToRect

Methods

Constructors

Properties

addAllEdges: ((cells: Cell[]) => Cell[])

Returns an array with the given cells and all edges that are connected to a cell or one of its descendants.

addCell: ((cell: Cell, parent: null | Cell, index?: null | number, source?: null | Cell, target?: null | Cell) => Cell)

Adds the cell to the parent and connects it to the given source and target terminals.

This is a shortcut method.

Type declaration

    • (cell, parent, index?, source?, target?): Cell
    • Parameters

      • cell: Cell

        mxCell to be inserted into the given parent.

      • parent: null | Cell

        mxCell that represents the new parent. If no parent is given then the default parent is used.

      • Optionalindex: null | number

        Optional index to insert the cells at. Default is 'to append'.

      • Optionalsource: null | Cell

        Optional Cell that represents the source terminal.

      • Optionaltarget: null | Cell

        Optional Cell that represents the target terminal.

      Returns Cell

      the cell that was added.

addCellOverlay: ((cell: Cell, overlay: CellOverlay) => CellOverlay)

Adds an CellOverlay for the specified cell.

This method fires an InternalEvent.ADD_OVERLAY event and returns the new CellOverlay.

Type declaration

addCells: ((cells: Cell[], parent: null | Cell, index: null | number, source: null | Cell, target: null | Cell, absolute?: boolean) => Cell[])

Adds the cells to the parent at the given index, connecting each cell to the optional source and target terminal. The change is carried out using cellsAdded. This method fires Event#ADD_CELLS while the transaction is in progress. Returns the cells that were added.

Type declaration

    • (cells, parent, index, source, target, absolute?): Cell[]
    • Parameters

      • cells: Cell[]

        Array of Cells to be inserted.

      • parent: null | Cell

        Cell that represents the new parent. If no parent is given then the default parent is used.

      • index: null | number

        Optional index to insert the cells at. Default is to append.

      • source: null | Cell

        Optional source Cell for all inserted cells.

      • target: null | Cell

        Optional target Cell for all inserted cells.

      • Optionalabsolute: boolean

        Optional boolean indicating of cells should be kept at their absolute position. Default is false.

      Returns Cell[]

addEdge: ((edge: Cell, parent: null | Cell, source: null | Cell, target: null | Cell, index?: null | number) => Cell)

Adds the edge to the parent and connects it to the given source and target terminals. This is a shortcut method.

Type declaration

    • (edge, parent, source, target, index?): Cell
    • Parameters

      • edge: Cell

        Cell to be inserted into the given parent.

      • parent: null | Cell

        Cell that represents the new parent. If no parent is given then the default parent is used.

      • source: null | Cell

        Optional Cell that represents the source terminal.

      • target: null | Cell

        Optional Cell that represents the target terminal.

      • Optionalindex: null | number

        Optional index to insert the cells at. Default is 'to append'.

      Returns Cell

      The edge that was added.

addImageBundle: ((bundle: ImageBundle) => void)

Adds the specified ImageBundle.

addMouseListener: ((listener: MouseListenerSet) => void)

Adds a listener to the graph event dispatch loop.

The listener must implement the mouseDown, mouseMove and mouseUp methods as shown in the InternalMouseEvent class.

Type declaration

    • (listener): void
    • Parameters

      Returns void

addSelectionCell: ((cell: Cell) => void)

Adds the given cell to the selection.

Type declaration

    • (cell): void
    • Parameters

      • cell: Cell

        Cell to be add to the selection.

      Returns void

addSelectionCells: ((cells: Cell[]) => void)

Adds the given cells to the selection.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell to be added to the selection.

      Returns void

alignCells: ((align: string, cells?: Cell[], param?: null | number) => void)

Aligns the given cells vertically or horizontally according to the given alignment using the optional parameter as the coordinate.

Type declaration

    • (align, cells?, param?): void
    • Parameters

      • align: string

        Specifies the alignment. Possible values are all entries of the ALIGN enum.

      • Optionalcells: Cell[]

        Array of Cell to be aligned.

      • Optionalparam: null | number

        Optional coordinate for the alignment.

      Returns void

allowAutoPanning: boolean

Specifies if panning via panGraph should be allowed to implement autoscroll if no scrollbars are available in scrollPointToVisible.

To enable panning inside the container, near the edge, set PanningManager.border to a positive value.

false
allowDanglingEdges: boolean

Specifies if edges with disconnected terminals are allowed in the graph.

true
allowLoops: boolean = false

Specifies if loops (aka self-references) are allowed.

false
allowNegativeCoordinates: boolean

Specifies if negative coordinates for vertices are allowed.

true
alreadyConnectedResource: string = ...

Specifies the resource key for the error message to be displayed in non-multigraphs when two vertices are already connected. If the resource for this key does not exist then the value is used as the error message.

'alreadyConnected'
alternateEdgeStyle: CellStyle

Specifies the alternate edge style to be used if the main control point on an edge is being double-clicked.

{}
autoExtend: boolean

Specifies if the size of the graph should be automatically extended if the mouse goes near the container edge while dragging.

This is only taken into account if the container has scrollbars.

See autoScroll.

true
autoScroll: boolean

Specifies if the graph should automatically scroll if the mouse goes near the container edge while dragging.

This is only taken into account if the container has scrollbars.

If you need this to work without scrollbars then set ignoreScrollbars to true. Please consult the ignoreScrollbars for details. In general, with no scrollbars, the use of allowAutoPanning is recommended.

true
autoSizeCell: ((cell: Cell, recurse?: boolean) => void)

Resizes the specified cell to just fit around its label and/or children.

Type declaration

    • (cell, recurse?): void
    • Parameters

      • cell: Cell

        mxCell to be resized.

      • Optionalrecurse: boolean

        Optional boolean which specifies if all descendants should be auto-sized. Default is true.

      Returns void

autoSizeCells: boolean

Specifies if the graph should automatically update the cell size after an edit. This is used in isAutoSizeCell.

false
autoSizeCellsOnAdd: boolean

Specifies if autoSize style should be applied when cells are added.

false
backgroundImage: null | ImageBox = null

Specifies the Image to be returned by getBackgroundImage.

null
var img = new mxImage('http://www.example.com/maps/examplemap.jpg', 1024, 768);
graph.setBackgroundImage(img);
graph.view.validate();
border: number = 0

Border to be added to the bottom and right side when the container is being resized after the graph has been changed.

0
canExportCell: ((cell: null | Cell) => boolean)

Returns true if the given cell may be exported to the clipboard.

This implementation returns exportEnabled for all cells.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: null | Cell

        Cell that represents the cell to be exported.

      Returns boolean

canImportCell: ((cell: null | Cell) => boolean)

Returns true if the given cell may be imported from the clipboard.

This implementation returns importEnabled for all cells.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: null | Cell

        Cell that represents the cell to be imported.

      Returns boolean

cellConnected: ((edge: Cell, terminal: null | Cell, source: boolean, constraint?: null | ConnectionConstraint) => void)

Sets the new terminal for the given edge and resets the edge points if resetEdgesOnConnect is true.

This method fires InternalEvent.CELL_CONNECTED while the transaction is in progress.

Type declaration

    • (edge, terminal, source, constraint?): void
    • Parameters

      • edge: Cell

        Cell whose terminal should be updated.

      • terminal: null | Cell

        Cell that represents the new terminal to be used.

      • source: boolean

        Boolean indicating if the new terminal is the source or target. Default is false.

      • Optionalconstraint: null | ConnectionConstraint

        ConnectionConstraint to be used for this connection.

      Returns void

cellLabelChanged: ((cell: Cell, value: any, autoSize: boolean) => void)

Sets the new label for a cell. If autoSize is true, then cellSizeUpdated will be called.

In the following example, the function is extended to map changes to attributes in an XML node, as shown in convertValueToString. Alternatively, the handling of this can be implemented as shown in GraphDataModel.valueForCellChanged without the need to clone the user object.

const graphCellLabelChanged = graph.cellLabelChanged;
graph.cellLabelChanged = function(cell, newValue, autoSize) {
// Cloned for correct undo/redo
const elt = cell.value.cloneNode(true);
elt.setAttribute('label', newValue);

newValue = elt;
graphCellLabelChanged.apply(this, arguments);
};

Type declaration

    • (cell, value, autoSize): void
    • Parameters

      • cell: Cell

        Cell whose label should be changed.

      • value: any

        New label to be assigned.

      • autoSize: boolean

        Boolean that specifies if cellSizeUpdated should be called.

      Returns void

cellRenderer: CellRenderer

Holds the CellRenderer for rendering the cells in the graph.

cellResized: ((cell: Cell, bounds: Rectangle, ignoreRelative: boolean, recurse: boolean) => null | Geometry)

Resizes the parents recursively so that they contain the complete area of the resized child cell.

Type declaration

    • (cell, bounds, ignoreRelative, recurse): null | Geometry
    • Parameters

      • cell: Cell

        Cell whose bounds should be changed.

      • bounds: Rectangle

        Rectangles that represent the new bounds.

      • ignoreRelative: boolean

        Boolean that indicates if relative cells should be ignored. Default is false.

      • recurse: boolean

        Optional boolean that specifies if the children should be resized. Default is false.

      Returns null | Geometry

cells: Cell[] = []
cellsAdded: ((cells: Cell[], parent: Cell, index: number, source: null | Cell, target: null | Cell, absolute: boolean, constrain?: boolean, extend?: boolean) => void)

Adds the specified cells to the given parent. This method fires Event#CELLS_ADDED while the transaction is in progress.

cellsBendable: boolean

Specifies the return value for isCellsBendable.

true
cellsCloneable: boolean

Specifies the return value for isCellCloneable.

true
cellsDeletable: boolean

Specifies the return value for isCellDeletable.

true
cellsDisconnectable: boolean

Specifies the return value for isCellsDisconnectable.

true
cellsEditable: boolean
true
cellsFolded: ((cells: null | Cell[], collapse: boolean, recurse: boolean, checkFoldable?: boolean) => void)

Sets the collapsed state of the specified cells.

This method fires InternalEvent.CELLS_FOLDED while the transaction is in progress.

Returns the cells whose collapsed state was changed.

Type declaration

    • (cells, collapse, recurse, checkFoldable?): void
    • Parameters

      • cells: null | Cell[]

        Array of Cell whose collapsed state should be set. Default is null.

      • collapse: boolean

        Boolean indicating the collapsed state to be assigned. Default is false.

      • recurse: boolean

        Boolean indicating if the collapsed state of all descendants should be set. Default is false.

      • OptionalcheckFoldable: boolean

        Optional boolean indicating of isCellFoldable should be checked. Default is false.

      Returns void

cellSizeUpdated: ((cell: Cell, ignoreChildren: boolean) => void)

Updates the size of the given cell in the model using getPreferredSizeForCell to get the new size.

Type declaration

    • (cell, ignoreChildren): void
    • Parameters

      • cell: Cell

        Cell for which the size should be changed.

      • ignoreChildren: boolean

        if true, ignore the children of the cell when computing the size of the cell. Default is false.

      Returns void

cellsLocked: boolean

Specifies the return value for isCellLocked.

false
cellsMovable: boolean

Specifies the return value for isCellMovable.

true
cellsMoved: ((cells: Cell[], dx: number, dy: number, disconnect: boolean, constrain: boolean, extend?: null | boolean) => void)

Moves the specified cells by the given vector, disconnecting the cells using disconnectGraph is disconnect is true.

This method fires InternalEvent.CELLS_MOVED while the transaction is in progress.

cellsOrdered: ((cells: Cell[], back: boolean) => void)

Moves the given cells to the front or back.

This method fires InternalEvent.CELLS_ORDERED while the transaction is in progress.

Type declaration

    • (cells, back): void
    • Parameters

      • cells: Cell[]

        Array of Cell whose order should be changed.

      • back: boolean

        Boolean that specifies if the cells should be moved to back. Default is false.

      Returns void

cellsRemoved: ((cells: Cell[]) => void)

Removes the given cells from the model. This method fires InternalEvent.CELLS_REMOVED while the transaction is in progress.

Type declaration

    • (cells): void
    • Parameters

      Returns void

cellsResizable: boolean

Specifies the return value for isCellsResizable.

true
cellsResized: ((cells: Cell[], bounds: Rectangle[], recurse: boolean) => void)

Sets the bounds of the given cells and fires a InternalEvent.CELLS_RESIZED event. If extendParents is true, then the parent is extended if a child size is changed so that it overlaps with the parent.

The following example shows how to control group resizes to make sure that all child cells stay within the group.

graph.addListener(mxEvent.CELLS_RESIZED, function(sender, evt)
{
var cells = evt.getProperty('cells');

if (cells != null)
{
for (var i = 0; i < cells.length; i++)
{
if (graph.getDataModel().getChildCount(cells[i]) > 0)
{
var geo = cells[i].getGeometry();

if (geo != null)
{
var children = graph.getChildCells(cells[i], true, true);
var bounds = graph.getBoundingBoxFromGeometry(children, true);

geo = geo.clone();
geo.width = Math.max(geo.width, bounds.width);
geo.height = Math.max(geo.height, bounds.height);

graph.getDataModel().setGeometry(cells[i], geo);
}
}
}
}
});

Type declaration

    • (cells, bounds, recurse): void
    • Parameters

      • cells: Cell[]

        Array of Cell whose bounds should be changed.

      • bounds: Rectangle[]

        Array of Rectangles that represent the new bounds.

      • recurse: boolean

        Optional boolean that specifies if the children should be resized. Default is false.

      Returns void

cellsSelectable: boolean

Specifies the return value for isCellsSelectable.

true
cellsToggled: ((cells: Cell[], show: boolean) => void)

Sets the visible state of the specified cells.

Type declaration

    • (cells, show): void
    • Parameters

      • cells: Cell[]

        Array of Cell whose visible state should be changed.

      • show: boolean

        Boolean that specifies the visible state to be assigned.

      Returns void

centerZoom: boolean

Specifies if the zoom operations should go into the center of the actual diagram rather than going from top, left.

true
clearCellOverlays: ((cell: null | Cell) => void)

Removes all CellOverlays in the graph for the given cell and all its descendants.

If no cell is specified then all overlays are removed from the graph.

This implementation uses removeCellOverlays to remove the overlays from the individual cells.

Type declaration

    • (cell): void
    • Parameters

      • cell: null | Cell

        Optional Cell that represents the root of the subtree to remove the overlays from. Default is the root in the model.

      Returns void

clearSelection: (() => void)

Clears the selection using GraphSelectionModel.clear.

click: ((me: InternalMouseEvent) => boolean)

Processes a single click on an optional cell and fires a click event. The click event is fired initially. If the graph is enabled and the event has not been consumed, then the cell is selected using selectCellForEvent or the selection is cleared using clearSelection.

The events consumed state is set to true if the corresponding InternalMouseEvent has been consumed.

To handle a click event, use the following code.

graph.addListener(InternalEvent.CLICK, function(sender, evt) {
const e = evt.getProperty('event'); // mouse event
const cell = evt.getProperty('cell'); // cell may be null

if (cell) {
// Do something useful with cell and consume the event
evt.consume();
}
});

Type declaration

    • (me): boolean
    • Parameters

      Returns boolean

cloneCell: ((cell: Cell, allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean) => Cell)

Returns the clone for the given cell. Uses cloneCells.

Type declaration

    • (cell, allowInvalidEdges?, mapping?, keepPosition?): Cell
    • Parameters

      • cell: Cell

        Cell to be cloned.

      • OptionalallowInvalidEdges: boolean

        Optional boolean that specifies if invalid edges should be cloned. Default is true.

      • Optionalmapping: any

        Optional mapping for existing clones.

      • OptionalkeepPosition: boolean

        Optional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false.

      Returns Cell

cloneCells: ((cells: Cell[], allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean) => Cell[])

Returns the clones for the given cells. The clones are created recursively using cloneCells.

If the terminal of an edge is not in the given array, then the respective end is assigned a terminal point and the terminal is removed.

Type declaration

    • (cells, allowInvalidEdges?, mapping?, keepPosition?): Cell[]
    • Parameters

      • cells: Cell[]

        Array of Cell to be cloned.

      • OptionalallowInvalidEdges: boolean

        Optional boolean that specifies if invalid edges should be cloned. Default is true.

      • Optionalmapping: any

        Optional mapping for existing clones.

      • OptionalkeepPosition: boolean

        Optional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false.

      Returns Cell[]

cloneInvalidEdges: boolean

Specifies if edges that are cloned should be validated and only inserted if they are valid.

false
collapseExpandResource: string

Specifies the resource key for the tooltip on the collapse/expand icon. If the resource for this key does not exist then the value is used as the tooltip.

'collapse-expand' is Client.language is not 'none'. Else, it is an empty string.

connectableEdges: boolean

Specifies if edges are connectable. This overrides the connectable field in edges.

false
connectCell: ((edge: Cell, terminal: null | Cell, source: boolean, constraint?: null | ConnectionConstraint) => Cell)

Connects the specified end of the given edge to the given terminal using cellConnected and fires InternalEvent.CONNECT_CELL while the transaction is in progress.

Type declaration

    • (edge, terminal, source, constraint?): Cell
    • Parameters

      • edge: Cell

        Cell whose terminal should be updated.

      • terminal: null | Cell

        Cell that represents the new terminal to be used.

      • source: boolean

        Boolean indicating if the new terminal is the source or target. Default is false.

      • Optionalconstraint: null | ConnectionConstraint

        Optional ConnectionConstraint to be used for this connection.

      Returns Cell

      the updated edge.

constrainChild: ((cell: Cell, sizeFirst?: boolean) => void)

Keeps the given cell inside the bounds returned by getCellContainmentArea for its parent, according to the rules defined by getOverlap and isConstrainChild.

This modifies the cell's geometry in-place and does not clone it.

Type declaration

    • (cell, sizeFirst?): void
    • Parameters

      • cell: Cell

        Cell which should be constrained.

      • OptionalsizeFirst: boolean

        Specifies if the size should be changed first. Default is true.

      Returns void

constrainChildCells: ((cell: Cell) => void)

Constrains the children of the given cell using constrainChild.

Type declaration

    • (cell): void
    • Parameters

      Returns void

constrainChildren: boolean

Specifies if a child should be constrained inside the parent bounds after a move or resize of the child.

true
constrainRelativeChildren: boolean

Specifies if child cells with relative geometries should be constrained inside the parent bounds, if constrainChildren is true, and/or the maximumGraphBounds.

false
consumeMouseEvent: ((evtName: string, me: InternalMouseEvent, sender: EventSource) => void)

Consumes the given InternalMouseEvent if it's a touchStart event.

container: HTMLElement
containsValidationErrorsResource: string = ...

Specifies the resource key for the warning message to be displayed when a collapsed cell contains validation errors. If the resource for this key does not exist then the value is used as the warning message.

'containsValidationErrors'
createEdge: ((parent: null | Cell, id: string, value: any, source: null | Cell, target: null | Cell, style?: CellStyle) => Cell)

Hook method that creates the new edge for insertEdge.

This implementation does not set the source and target of the edge, these are set when the edge is added to the model.

Type declaration

    • (parent, id, value, source, target, style?): Cell
    • Parameters

      • parent: null | Cell

        Cell that specifies the parent of the new edge. If not set, use the default parent.

      • id: string

        Optional string that defines the Id of the new edge. If not set, the id is auto-generated when creating the vertex.

      • value: any

        Object to be used as the user object which is generally used to display the label of the edge. The default implementation handles string object.

      • source: null | Cell

        Cell that defines the source of the edge.

      • target: null | Cell

        Cell that defines the target of the edge.

      • Optionalstyle: CellStyle

        Optional object that defines the cell style.

      Returns Cell

createGroupCell: ((cells: Cell[]) => Cell)

Hook for creating the group cell to hold the given array of Cell if no group cell was given to the group function.

The following code can be used to set the style of new group cells.

const graphCreateGroupCell = graph.createGroupCell;
graph.createGroupCell = function(cells) {
const group = graphCreateGroupCell.apply(this, arguments);
group.setStyle('group');

return group;
dblClick: ((evt: MouseEvent, cell?: null | Cell) => void)

Processes a double click on an optional cell and fires a dblclick event. The event is fired initially.

If the graph is enabled and the event has not been consumed, then edit is called with the given cell. The event is ignored if no cell was specified.

Example for overriding this method.

graph.dblClick = function(evt, cell) {
const mxe = new EventObject(InternalEvent.DOUBLE_CLICK, 'event', evt, 'cell', cell);
this.fireEvent(mxe);

if (this.isEnabled() && !InternalEvent.isConsumed(evt) && !mxe.isConsumed()) {
alert('Hello, World!');
mxe.consume();
}
}

Example listener for this event.

graph.addListener(InternalEvent.DOUBLE_CLICK, function(sender, evt) {
const cell = evt.getProperty('cell');
// do something with the cell and consume the
// event to prevent in-place editing from start
});

Type declaration

    • (evt, cell?): void
    • Parameters

      • evt: MouseEvent

        Mouseevent that represents the double click.

      • Optionalcell: null | Cell

        Optional Cell under the mouse pointer.

      Returns void

defaultLoopStyle: EdgeStyleFunction = EdgeStyle.Loop

EdgeStyle to be used for loops. This is a fallback for loops if the CellStateStyle.loopStyle is undefined.

defaultOverlap: number = 0.5

Value returned by getOverlap if isAllowOverlapParent returns true for the given cell. getOverlap is used in constrainChild if isConstrainChild returns true. The value specifies the portion of the child which is allowed to overlap the parent.

defaultParent: null | Cell = null

Specifies the default parent to be used to insert new cells. This is used in getDefaultParent.

null
destroyed: boolean = false
dialect:
    | "svg"
    | "mixedHtml"
    | "preferHtml"
    | "strictHtml" = 'svg'

Dialect to be used for drawing the graph. Possible values are all constants in DIALECT.

disconnectGraph: ((cells: Cell[]) => void)

Disconnects the given edges from the terminals which are not in the given array.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell to be disconnected.

      Returns void

disconnectOnMove: boolean

Specifies if edges should be disconnected from their terminals when they are moved.

true
doneResource: string
doubleClickCounter: number
doubleTapEnabled: boolean

Specifies if double taps on touch-based devices should be handled as a double click.

true
doubleTapTimeout: number

Specifies the timeout in milliseconds for double taps and non-native double clicks.

500
doubleTapTolerance: number

Specifies the tolerance in pixels for double taps and double-clicks in quirks mode.

25
dropEnabled: boolean

Specifies the return value for isDropEnabled.

false
edgeLabelsMovable: boolean

Specifies the return value for edges in isLabelMovable.

true
enabled: boolean = true

Specifies the return value for isEnabled.

true
enterGroup: ((cell: Cell) => void)

Uses the given cell as the root of the displayed cell hierarchy. If no cell is specified then the selection cell is used.

The cell is only used if isValidRoot returns true.

Type declaration

    • (cell): void
    • Parameters

      • cell: Cell

        Optional Cell to be used as the new root. Default is the selection cell.

      Returns void

enterStopsCellEditing: boolean

If true, pressing the enter key without pressing control or shift will stop editing and accept the new value. This is used in CellEditorHandler to stop cell editing. Note: You can always use F2 and escape to stop editing.

false
escape: ((evt: Event) => void)

Processes an escape keystroke.

Type declaration

    • (evt): void
    • Parameters

      • evt: Event

        Event that represents the keystroke.

      Returns void

escapeEnabled: boolean

Specifies if KeyHandler should invoke escape when the escape key is pressed.

true
eventListeners: EventListenerObject[] = []

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

eventsEnabled: boolean = true

Specifies if events can be fired. Default is true.

eventSource: null | EventTarget = null

Optional source for events. Default is null.

exitGroup: (() => void)

Changes the current root to the next valid root in the displayed cell hierarchy.

exportEnabled: boolean = true

Specifies the return value for canExportCell.

true
extendParent: ((cell: Cell) => void)

Resizes the parents recursively so that they contain the complete area of the resized child cell.

Type declaration

    • (cell): void
    • Parameters

      Returns void

extendParents: boolean

Specifies if a parent should contain the child bounds after a resize of the child. This has precedence over constrainChildren.

true
extendParentsOnAdd: boolean

Specifies if parents should be extended according to the extendParents switch if cells are added.

true
extendParentsOnMove: boolean

Specifies if parents should be extended according to the extendParents switch if cells are added.

false (for backwards compatibility)
fireDoubleClick: null | boolean
fireGestureEvent: ((evt: MouseEvent, cell?: null | Cell) => void)

Dispatches a InternalEvent.GESTURE event. The following example will resize the cell under the mouse based on the scale property of the native touch event.

graph.addListener(mxEvent.GESTURE, function(sender, eo) {
const evt = eo.getProperty('event');
const state = graph.view.getState(eo.getProperty('cell'));

if (graph.isEnabled() && graph.isCellResizable(state.cell) && Math.abs(1 - evt.scale) > 0.2) {
const scale = graph.view.scale;
const tr = graph.view.translate;

const w = state.width * evt.scale;
const h = state.height * evt.scale;
const x = state.x - (w - state.width) / 2;
const y = state.y - (h - state.height) / 2;

const bounds = new Rectangle(graph.snap(x / scale) - tr.x,
graph.snap(y / scale) - tr.y,
graph.snap(w / scale),
graph.snap(h / scale));
graph.resizeCell(state.cell, bounds);
eo.consume();
}
});

Type declaration

    • (evt, cell?): void
    • Parameters

      • evt: MouseEvent

        MouseEvent event that represents the gesture.

      • Optionalcell: null | Cell

        Optional Cell associated with the gesture.

      Returns void

fireMouseEvent: ((evtName: string, me: InternalMouseEvent, sender?: EventSource) => void)

Dispatches the given event in the graph event dispatch loop.

Possible event names are InternalEvent.MOUSE_DOWN, InternalEvent.MOUSE_MOVE and InternalEvent.MOUSE_UP. All listeners are invoked for all events regardless of the consumed state of the event.

Type declaration

    • (evtName, me, sender?): void
    • Parameters

      Returns void

flipEdge: ((edge: Cell) => Cell)

Toggles the style of the given edge between null (or empty) and alternateEdgeStyle.

This method fires InternalEvent.FLIP_EDGE while the transaction is in progress.

Here is an example that overrides this implementation to invert the value of CellStateStyle.elbow without removing any existing styles.

graph.flipEdge = function(edge) {
if (edge) {
const style = this.getCurrentCellStyle(edge);
const elbow = style.elbow ?? Constants.ELBOW.HORIZONTAL;
const value = (elbow == Constants.ELBOW.HORIZONTAL) ? Constants.ELBOW.VERTICAL : Constants.ELBOW.HORIZONTAL;
this.setCellStyles('elbow', value, [edge]);
}
};

Type declaration

    • (edge): Cell
    • Parameters

      • edge: Cell

        Cell whose style should be changed.

      Returns Cell

      The edge that was flipped.

foldCells: ((collapse: boolean, recurse?: boolean, cells?: null | Cell[], checkFoldable?: boolean, evt?: null | Event) => null | Cell[])

Sets the collapsed state of the specified cells and all descendants if recurse is true. The change is carried out using cellsFolded.

This method fires InternalEvent.FOLD_CELLS while the transaction is in progress.

Returns the cells whose collapsed state was changed.

Type declaration

    • (collapse, recurse?, cells?, checkFoldable?, evt?): null | Cell[]
    • Parameters

      • collapse: boolean

        Boolean indicating the collapsed state to be assigned. Default is false.

      • Optionalrecurse: boolean

        Optional boolean indicating if the collapsed state of all descendants should be set. Default is false.

      • Optionalcells: null | Cell[]

        Array of Cell whose collapsed state should be set. If null is specified then the foldable selection cells are used. Default is null.

      • OptionalcheckFoldable: boolean

        Optional boolean indicating of isCellFoldable should be checked. Default is false.

      • Optionalevt: null | Event

        Optional native event that triggered the invocation. Default is null.

      Returns null | Cell[]

getActualStartSize: ((swimlane: Cell, ignoreState: boolean) => Rectangle)

Returns the actual start size of the given swimlane taking into account direction and horizontal and vertical flip styles. The start size is returned as an Rectangle where top, left, bottom, right start sizes are returned as x, y, height and width, respectively.

Type declaration

    • (swimlane, ignoreState): Rectangle
    • Parameters

      • swimlane: Cell

        mxCell whose start size should be returned.

      • ignoreState: boolean

        Optional boolean that specifies if cell state should be ignored.

      Returns Rectangle

getAllConnectionConstraints: ((terminal: null | CellState, source: boolean) => null | ConnectionConstraint[])

Returns an array of all ConnectionConstraints for the given terminal. If the shape of the given terminal is a StencilShape then the constraints of the corresponding StencilShape are returned.

Type declaration

getAllEdges: ((cells: null | Cell[]) => Cell[])

Returns all edges connected to the given cells or its descendants.

getBoundingBox: ((cells: Cell[]) => null | Rectangle)

Returns the bounding box for the given array of Cell. The bounding box for each cell and its descendants is computed using view.getBoundingBox.

Type declaration

getBoundingBoxFromGeometry: ((cells: Cell[], includeEdges?: boolean) => null | Rectangle)

Returns the bounding box for the geometries of the vertices in the given array of cells. This can be used to find the graph bounds during a layout operation (ie. before the last endUpdate) as follows:

var cells = graph.getChildCells(graph.getDefaultParent(), true, true);
var bounds = graph.getBoundingBoxFromGeometry(cells, true);

This can then be used to move cells to the origin:

if (bounds.x < 0 || bounds.y < 0)
{
graph.moveCells(cells, -Math.min(bounds.x, 0), -Math.min(bounds.y, 0))
}

Or to translate the graph view:

if (bounds.x < 0 || bounds.y < 0)
{
getView().setTranslate(-Math.min(bounds.x, 0), -Math.min(bounds.y, 0));
}

Type declaration

    • (cells, includeEdges?): null | Rectangle
    • Parameters

      • cells: Cell[]

        Array of Cell whose bounds should be returned.

      • OptionalincludeEdges: boolean

        Specifies if edge bounds should be included by computing the bounding box for all points in geometry. Default is false.

      Returns null | Rectangle

getBoundsForGroup: ((group: Cell, children: Cell[], border: null | number) => null | Rectangle)

Returns the bounds to be used for the given group and children.

getCellAt: ((x: number, y: number, parent?: null | Cell, vertices?: null | boolean, edges?: null | boolean, ignoreFn?: null | Function) => null | Cell)

Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.

This will also return swimlanes if the given location intersects the content area of the swimlane. If this is not desired, then the hitsSwimlaneContent may be used if the returned cell is a swimlane to determine if the location is inside the content area or on the actual title of the swimlane.

Type declaration

    • (x, y, parent?, vertices?, edges?, ignoreFn?): null | Cell
    • Parameters

      • x: number

        X-coordinate of the location to be checked.

      • y: number

        Y-coordinate of the location to be checked.

      • Optionalparent: null | Cell

        mxCell that should be used as the root of the recursion. Default is current root of the view or the root of the model.

      • Optionalvertices: null | boolean

        Optional boolean indicating if vertices should be returned. Default is true.

      • Optionaledges: null | boolean

        Optional boolean indicating if edges should be returned. Default is true.

      • OptionalignoreFn: null | Function

        Optional function that returns true if cell should be ignored. The function is passed the cell state and the x and y parameter. Default is null.

      Returns null | Cell

getCellBounds: ((cell: Cell, includeEdges?: boolean, includeDescendants?: boolean) => null | Rectangle)

Returns the scaled, translated bounds for the given cell. See GraphView.getBounds for arrays.

Type declaration

    • (cell, includeEdges?, includeDescendants?): null | Rectangle
    • Parameters

      • cell: Cell

        Cell whose bounds should be returned.

      • OptionalincludeEdges: boolean

        Optional boolean that specifies if the bounds of the connected edges should be included. Default is false.

      • OptionalincludeDescendants: boolean

        Optional boolean that specifies if the bounds of all descendants should be included. Default is false.

      Returns null | Rectangle

getCellContainmentArea: ((cell: Cell) => null | Rectangle)

Returns the Rectangle inside which a cell is to be kept.

Type declaration

getCellOverlays: ((cell: Cell) => CellOverlay[])

Returns an array of CellOverlays for the given cell or null, if no overlays are defined.

Type declaration

getCells: ((x: number, y: number, width: number, height: number, parent?: null | Cell, result?: Cell[], intersection?: null | Rectangle, ignoreFn?: null | Function, includeDescendants?: boolean) => Cell[])

Returns the child vertices and edges of the given parent that are contained in the given rectangle.

The result is added to the optional result array, which is returned. If no result array is specified then a new array is created and returned.

Type declaration

    • (x, y, width, height, parent?, result?, intersection?, ignoreFn?, includeDescendants?): Cell[]
    • Parameters

      • x: number

        X-coordinate of the rectangle.

      • y: number

        Y-coordinate of the rectangle.

      • width: number

        Width of the rectangle.

      • height: number

        Height of the rectangle.

      • Optionalparent: null | Cell

        mxCell that should be used as the root of the recursion. Default is current root of the view or the root of the model.

      • Optionalresult: Cell[]

        Optional array to store the result in. Default is an empty Array.

      • Optionalintersection: null | Rectangle

        Default is null.

      • OptionalignoreFn: null | Function

        Default is null.

      • OptionalincludeDescendants: boolean

        Default is false.

      Returns Cell[]

getCellsBeyond: ((x0: number, y0: number, parent: null | Cell, rightHalfpane: boolean, bottomHalfpane: boolean) => Cell[])

Returns the children of the given parent that are contained in the half-pane from the given point (x0, y0) rightwards or downwards depending on rightHalfpane and bottomHalfpane.

Type declaration

    • (x0, y0, parent, rightHalfpane, bottomHalfpane): Cell[]
    • Parameters

      • x0: number

        X-coordinate of the origin.

      • y0: number

        Y-coordinate of the origin.

      • parent: null | Cell

        Optional Cell whose children should be checked. Default is .

      • rightHalfpane: boolean

        Boolean indicating if the cells in the right halfpane from the origin should be returned. Default is false.

      • bottomHalfpane: boolean

        Boolean indicating if the cells in the bottom halfpane from the origin should be returned. Default is false.

      Returns Cell[]

getCellsForGroup: ((cells: Cell[]) => Cell[])

Returns the cells with the same parent as the first cell in the given array.

getCellsForUngroup: (() => Cell[])

Returns the selection cells that can be ungrouped.

getCellStyle: ((cell: Cell) => CellStateStyle)

Returns the computed style of the Cell using the edge or vertex default style regarding of the type of the cell. The actual computation is done by Stylesheet.getCellStyle.

Note: You should try and get the cell state for the given cell and use the cached style in the state before using this method.

Type declaration

getCellValidationError: ((cell: Cell) => null | string)

Checks all multiplicities that cannot be enforced while the graph is being modified, namely, all multiplicities that require a minimum of 1 edge.

Type declaration

    • (cell): null | string
    • Parameters

      • cell: Cell

        Cell for which the multiplicities should be checked.

      Returns null | string

getChildCells: ((parent?: null | Cell, vertices?: boolean, edges?: boolean) => Cell[])

Returns the visible child vertices or edges in the given parent.

If vertices and edges is false, then all children are returned.

Type declaration

    • (parent?, vertices?, edges?): Cell[]
    • Parameters

      • Optionalparent: null | Cell

        mxCell whose children should be returned.

      • Optionalvertices: boolean

        Optional boolean that specifies if child vertices should be returned. Default is false.

      • Optionaledges: boolean

        Optional boolean that specifies if child edges should be returned. Default is false.

      Returns Cell[]

getChildEdges: ((parent: Cell) => Cell[])

Returns the visible child edges of the given parent.

Type declaration

    • (parent): Cell[]
    • Parameters

      • parent: Cell

        Cell whose child vertices should be returned.

      Returns Cell[]

getChildVertices: ((parent?: null | Cell) => Cell[])

Returns the visible child vertices of the given parent.

Type declaration

    • (parent?): Cell[]
    • Parameters

      • Optionalparent: null | Cell

        the Cell whose children should be returned.

      Returns Cell[]

getCloneableCells: ((cells: Cell[]) => Cell[])

Returns the cells which may be exported in the given array of cells.

getCollapseExpandResource: (() => string)
getConnectionConstraint: ((edge: CellState, terminal: null | CellState, source: boolean) => ConnectionConstraint)

Returns an ConnectionConstraint that describes the given connection point. This result can then be passed to getConnectionPoint.

Type declaration

getConnectionPoint: ((vertex: CellState, constraint: ConnectionConstraint, round?: boolean) => null | Point)

Returns the nearest point in the list of absolute points or the center of the opposite terminal.

Type declaration

getConnections: ((cell: Cell, parent?: null | Cell) => Cell[])

Returns all visible edges connected to the given cell without loops.

Type declaration

    • (cell, parent?): Cell[]
    • Parameters

      • cell: Cell

        Cell whose connections should be returned.

      • Optionalparent: null | Cell

        Optional parent of the opposite end for a connection to be returned.

      Returns Cell[]

getCurrentCellStyle: ((cell: Cell, ignoreState?: boolean) => CellStateStyle)

Returns the style for the given cell from the cell state, if one exists, or using getCellStyle.

Type declaration

    • (cell, ignoreState?): CellStateStyle
    • Parameters

      • cell: Cell

        Cell whose style should be returned as an array.

      • OptionalignoreState: boolean

        Optional boolean that specifies if the cell state should be ignored.

      Returns CellStateStyle

getCursorForCell: ((cell: Cell) => null | string)

Returns the cursor value to be used for the CSS of the shape for the given cell.

This implementation returns null.

Type declaration

    • (cell): null | string
    • Parameters

      • cell: Cell

        Cell whose cursor should be returned.

      Returns null | string

getCursorForMouseEvent: ((me: InternalMouseEvent) => null | string)

Returns the cursor value to be used for the CSS of the shape for the given event.

This implementation calls getCursorForCell.

Type declaration

getDeletableCells: ((cells: Cell[]) => Cell[])

Returns the cells which may be exported in the given array of cells.

getDropTarget: ((cells: Cell[], evt: MouseEvent, cell: null | Cell, clone?: boolean) => null | Cell)

Returns the given cell if it is a drop target for the given cells or the nearest ancestor that may be used as a drop target for the given cells.

If the given array contains a swimlane and swimlaneNesting is false then this always returns null. If no cell is given, then the bottommost swimlane at the location of the given event is returned.

This function should only be used if isDropEnabled returns true.

Type declaration

    • (cells, evt, cell, clone?): null | Cell
    • Parameters

      • cells: Cell[]

        Array of Cell which are to be dropped onto the target.

      • evt: MouseEvent

        Mouse event for the drag and drop.

      • cell: null | Cell

        Cell that is under the mouse pointer.

      • Optionalclone: boolean

        Optional boolean to indicate of cells will be cloned.

      Returns null | Cell

getEdges: ((cell: Cell, parent?: null | Cell, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean, recurse?: boolean) => Cell[])

Returns the incoming and/or outgoing edges for the given cell.

If the optional parent argument is specified, then only edges are returned where the opposite is in the given parent cell.

If at least one of incoming or outgoing is true, then loops are ignored, if both are false, then all edges connected to the given cell are returned including loops.

Type declaration

    • (cell, parent?, incoming?, outgoing?, includeLoops?, recurse?): Cell[]
    • Parameters

      • cell: Cell

        Cell whose edges should be returned.

      • Optionalparent: null | Cell

        Optional parent of the opposite end for an edge to be returned.

      • Optionalincoming: boolean

        Optional boolean that specifies if incoming edges should be included in the result. Default is true.

      • Optionaloutgoing: boolean

        Optional boolean that specifies if outgoing edges should be included in the result. Default is true.

      • OptionalincludeLoops: boolean

        Optional boolean that specifies if loops should be included in the result. Default is true.

      • Optionalrecurse: boolean

        Optional boolean the specifies if the parent specified only needs to be an ancestral parent, true, or the direct parent, false. Default is false.

      Returns Cell[]

getEdgesBetween: ((source: Cell, target: Cell, directed?: boolean) => Cell[])

Returns the edges between the given source and target. This takes into account collapsed and invisible cells and returns the connected edges as displayed on the screen.

Type declaration

    • (source, target, directed?): Cell[]
    • Parameters

      • source: Cell
      • target: Cell
      • Optionaldirected: boolean

        If set to true, only returns the directed edges i.e. edges whose source is source and target is target. Default is false.

      Returns Cell[]

getEdgeValidationError: ((edge: null | Cell, source: null | Cell, target: null | Cell) => null | string)

Returns the validation error message to be displayed when inserting or changing an edges' connectivity. A return value of null means the edge is valid, a return value of '' means it's not valid, but do not display an error message. Any other (non-empty) string returned from this method is displayed as an error message when trying to connect an edge to a source and target. This implementation uses the multiplicities, and checks multigraph, allowDanglingEdges and allowLoops to generate validation errors.

For extending this method with specific checks for source/target cells, the method can be extended as follows. Returning an empty string means the edge is invalid with no error message, a non-null string specifies the error message, and null means the edge is valid.

graph.getEdgeValidationError = function(edge, source, target)
{
if (source != null && target != null &&
this.model.getValue(source) != null &&
this.model.getValue(target) != null)
{
if (target is not valid for source)
{
return 'Invalid Target';
}
}

// "Supercall"
return getEdgeValidationError.apply(this, arguments);
}

Type declaration

    • (edge, source, target): null | string
    • Parameters

      • edge: null | Cell

        Cell that represents the edge to validate.

      • source: null | Cell

        Cell that represents the source terminal.

      • target: null | Cell

        Cell that represents the target terminal.

      Returns null | string

getEditingValue: ((cell: Cell, evt: null | MouseEvent) => string)

Returns the initial value for in-place editing.

This implementation returns convertValueToString for the given cell. If this function is overridden, then GraphDataModel.valueForCellChanged should take care of correctly storing the actual new value inside the user object.

Type declaration

    • (cell, evt): string
    • Parameters

      • cell: Cell

        Cell for which the initial editing value should be returned.

      • evt: null | MouseEvent

        Optional mouse event that triggered the editor.

      Returns string

getEventState: ((state: CellState) => CellState)

Returns the CellState to be used when firing the mouse event for the given state.

This implementation returns the given state.

getEventTolerance: (() => number)
getExportableCells: ((cells: Cell[]) => Cell[])

Returns the cells which may be exported in the given array of cells.

getFoldableCells: ((cells: Cell[], collapse: boolean) => null | Cell[])

Returns the cells which are movable in the given array of cells.

getFoldingImage: ((state: CellState) => null | ImageBox)

Returns the Image used to display the collapsed state of the specified cell state.

This returns null for all edges.

getGridSize: (() => number)

Returns gridSize.

getImageFromBundles: ((key: string) => null | string)

Searches all imageBundles for the specified key and returns the value for the first match or null if the key is not found.

getImportableCells: ((cells: Cell[]) => Cell[])

Returns the cells which may be imported in the given array of cells.

getIncomingEdges: ((cell: Cell, parent: null | Cell) => Cell[])

Returns the visible incoming edges for the given cell. If the optional parent argument is specified, then only child edges of the given parent are returned.

Type declaration

    • (cell, parent): Cell[]
    • Parameters

      • cell: Cell

        Cell whose incoming edges should be returned.

      • parent: null | Cell

        Optional parent of the opposite end for an edge to be returned.

      Returns Cell[]

getLabel: ((cell: Cell) => null | string)

Returns a string or DOM node that represents the label for the given cell.

This implementation uses convertValueToString if labelsVisible is true. Otherwise, it returns an empty string.

To truncate a label to match the size of the cell, the following code can be used.

const getLabel = graph.getLabel;
graph.getLabel = function(cell) {
const label = getLabel.apply(this, arguments);

if (label && this.model.isVertex(cell)) {
const geo = cell.getCellGeometry();

if (geo) {
const max = parseInt(geo.width / 8);

if (label.length > max) {
label = label.substring(0, max) + '...';
}
}
}
return StringUtils.htmlEntities(label);
}

A resize listener is needed in the graph to force a repaint of the label after a resize.

graph.addListener(mxEvent.RESIZE_CELLS, function(sender, evt) {
const cells = evt.getProperty('cells');

for (let i = 0; i < cells.length; i++) {
this.view.removeState(cells[i]);
}
});

Type declaration

    • (cell): null | string
    • Parameters

      • cell: Cell

        mxCell whose label should be returned.

      Returns null | string

getMovableCells: ((cells: Cell[]) => Cell[])

Returns the cells which are movable in the given array of cells.

getOpposites: ((edges: Cell[], terminal: null | Cell, includeSources?: boolean, includeTargets?: boolean) => Cell[])

Returns all distinct visible opposite cells for the specified terminal on the given edges.

Type declaration

    • (edges, terminal, includeSources?, includeTargets?): Cell[]
    • Parameters

      • edges: Cell[]

        Array of Cell that contains the edges whose opposite terminals should be returned.

      • terminal: null | Cell

        Terminal that specifies the end whose opposite should be returned. Default is null.

      • OptionalincludeSources: boolean

        Optional boolean that specifies if source terminals should be included in the result. Default is true.

      • OptionalincludeTargets: boolean

        Optional boolean that specifies if target terminals should be included in the result. Default is true.

      Returns Cell[]

getOutgoingEdges: ((cell: Cell, parent: null | Cell) => Cell[])

Returns the visible outgoing edges for the given cell. If the optional parent argument is specified, then only child edges of the given parent are returned.

Type declaration

    • (cell, parent): Cell[]
    • Parameters

      • cell: Cell

        Cell whose outgoing edges should be returned.

      • parent: null | Cell

        Optional parent of the opposite end for an edge to be returned.

      Returns Cell[]

getOutlineConstraint: ((point: Point, terminalState: CellState, me: InternalMouseEvent) => null | ConnectionConstraint)

Returns the constraint used to connect to the outline of the given state.

getPanDx: (() => number)
getPanDy: (() => number)
getPointForEvent: ((evt: MouseEvent, addOffset?: boolean) => Point)

Returns an Point representing the given event in the unscaled, non-translated coordinate space of container and applies the grid.

Type declaration

    • (evt, addOffset?): Point
    • Parameters

      • evt: MouseEvent

        MouseEvent that contains the mouse pointer location.

      • OptionaladdOffset: boolean

        Optional boolean that specifies if the position should be offset by half of the gridSize. Default is true.

      Returns Point

getPreferredSizeForCell: ((cell: Cell, textWidth?: null | number) => null | Rectangle)

Returns the preferred width and height of the given Cell as an Rectangle. To implement a minimum width, add a new style e.g. minWidth in the vertex and override this method as follows.

var graphGetPreferredSizeForCell = graph.getPreferredSizeForCell;
graph.getPreferredSizeForCell(cell)
{
var result = graphGetPreferredSizeForCell.apply(this, arguments);
var style = this.getCellStyle(cell);

if (style.minWidth > 0)
{
result.width = Math.max(style.minWidth, result.width);
}

return result;
};

Type declaration

    • (cell, textWidth?): null | Rectangle
    • Parameters

      • cell: Cell

        mxCell for which the preferred size should be returned.

      • OptionaltextWidth: null | number

        Optional maximum text width for word wrapping.

      Returns null | Rectangle

getSelectionCell: (() => Cell)

Returns the first cell from the array of selected Cell.

getSelectionCells: (() => Cell[])

Returns the array of selected Cell.

getSelectionCellsForChanges: ((changes: any[], ignoreFn?: null | Function) => Cell[])

Returns the cells to be selected for the given array of changes.

Type declaration

    • (changes, ignoreFn?): Cell[]
    • Parameters

      • changes: any[]
      • OptionalignoreFn: null | Function

        Optional function that takes a change and returns true if the change should be ignored.

      Returns Cell[]

getSelectionCount: (() => number)

Returns the number of selected cells.

getSelectionModel: (() => GraphSelectionModel)

Returns the GraphSelectionModel that contains the selection.

getSnapTolerance: (() => number)
getStartSize: ((swimlane: Cell, ignoreState?: boolean) => Rectangle)

Returns the start size of the given swimlane, that is, the width or height of the part that contains the title, depending on the horizontal style. The return value is an Rectangle with either width or height set as appropriate.

Type declaration

    • (swimlane, ignoreState?): Rectangle
    • Parameters

      • swimlane: Cell

        mxCell whose start size should be returned.

      • OptionalignoreState: boolean

        Optional boolean that specifies if cell state should be ignored.

      Returns Rectangle

getStateForTouchEvent: ((evt: MouseEvent) => null | CellState)

Returns the state for the given touch event.

getSwimlane: ((cell: null | Cell) => null | Cell)

Returns the nearest ancestor of the given cell which is a swimlane, or the given cell, if it is itself a swimlane.

Type declaration

    • (cell): null | Cell
    • Parameters

      • cell: null | Cell

        Cell for which the ancestor swimlane should be returned.

      Returns null | Cell

getSwimlaneAt: ((x: number, y: number, parent?: null | Cell) => null | Cell)

Returns the bottom-most swimlane that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.

Type declaration

    • (x, y, parent?): null | Cell
    • Parameters

      • x: number

        X-coordinate of the location to be checked.

      • y: number

        Y-coordinate of the location to be checked.

      • Optionalparent: null | Cell

        mxCell that should be used as the root of the recursion. Default is defaultParent.

      Returns null | Cell

getSwimlaneDirection: ((style: CellStateStyle) => DirectionValue)

Returns the direction for the given swimlane style.

getTerminalForPort: ((cell: Cell, source?: boolean) => null | Cell)

Returns the terminal to be used for a given port.

This implementation always returns the parent cell.

Type declaration

    • (cell, source?): null | Cell
    • Parameters

      • cell: Cell

        Cell that represents the port.

      • Optionalsource: boolean

        If the cell is the source or target port. Default is false.

      Returns null | Cell

getTooltip: ((state: CellState, node: HTMLElement | SVGElement, x: number, y: number) => null | string | HTMLElement)

Returns the string or DOM node that represents the tooltip for the given state, node and coordinate pair. This implementation checks if the given node is a folding icon or overlay and returns the respective tooltip. If this does not result in a tooltip, the handler for the cell is retrieved from SelectionCellsHandler and the optional getTooltipForNode method is called. If no special tooltip exists here then getTooltipForCell is used with the cell in the given state as the argument to return a tooltip for the given state.

Type declaration

    • (state, node, x, y): null | string | HTMLElement
    • Parameters

      • state: CellState

        CellState whose tooltip should be returned.

      • node: HTMLElement | SVGElement

        DOM node that is currently under the mouse.

      • x: number

        X-coordinate of the mouse.

      • y: number

        Y-coordinate of the mouse.

      Returns null | string | HTMLElement

getTooltipForCell: ((cell: Cell) => string | HTMLElement)

Returns the string or DOM node to be used as the tooltip for the given cell. This implementation uses the Cell.getTooltip function if it exists, or else it returns convertValueToString for the cell.

Type declaration

    • (cell): string | HTMLElement
    • Parameters

      • cell: Cell

        Cell whose tooltip should be returned.

      Returns string | HTMLElement

graph.getTooltipForCell = function(cell)
{
return 'Hello, World!';
}

Replaces all tooltips with the string Hello, World!

graphModelChangeListener: null | Function = null
gridEnabled: boolean

Specifies if the grid is enabled. This is used in snap.

true
gridSize: number

Specifies the grid size.

10
groupCells: ((group: Cell, border: number, cells?: null | Cell[]) => Cell)

Adds the cells into the given group. The change is carried out using cellsAdded, cellsMoved and cellsResized.

This method fires InternalEvent.GROUP_CELLS while the transaction is in progress.

Type declaration

    • (group, border, cells?): Cell
    • Parameters

      • group: Cell

        Cell that represents the target group. If null is specified then a new group is created using createGroupCell.

      • border: number

        Optional integer that specifies the border between the child area and the group bounds. Default is 0.

      • Optionalcells: null | Cell[]

        Optional array of Cell to be grouped. If null is specified then the selection cells are used.

      Returns Cell

      the new group. A group is only created if there is at least one entry in the given array of cells.

hitsSwimlaneContent: ((swimlane: Cell, x: number, y: number) => boolean)

Returns true if the given coordinate pair is inside the content are of the given swimlane.

Type declaration

    • (swimlane, x, y): boolean
    • Parameters

      • swimlane: Cell

        Cell that specifies the swimlane.

      • x: number

        X-coordinate of the mouse event.

      • y: number

        Y-coordinate of the mouse event.

      Returns boolean

horizontalPageBreaks: null | any[]
null
htmlLabels: boolean

Specifies the return value for isHtmlLabel.

false
ignoreMouseEvents: null | boolean
ignoreScrollbars: boolean = false

Specifies if the graph should automatically scroll regardless of the scrollbars. This will scroll the container using positive values for scroll positions (ie usually only rightwards and downwards). To avoid possible conflicts with panning, set translateToScrollPosition to true.

imageBundles: ImageBundle[] = []
importCells: ((cells: Cell[], dx?: number, dy?: number, target?: null | Cell, evt?: null | MouseEvent, mapping?: any) => Cell[])

Clones and inserts the given cells into the graph using the move method and returns the inserted cells. This shortcut is used if cells are inserted via data transfer.

Type declaration

    • (cells, dx?, dy?, target?, evt?, mapping?): Cell[]
    • Parameters

      • cells: Cell[]

        Array of Cell to be imported.

      • Optionaldx: number

        Integer that specifies the x-coordinate of the vector. Default is 0.

      • Optionaldy: number

        Integer that specifies the y-coordinate of the vector. Default is 0.

      • Optionaltarget: null | Cell

        Cell that represents the new parent of the cells.

      • Optionalevt: null | MouseEvent

        MouseEvent that triggered the invocation.

      • Optionalmapping: any

        Optional mapping for existing clones.

      Returns Cell[]

      the cells that were imported.

importEnabled: boolean = true

Specifies the return value for canImportCell.

true
initialTouchX: number

Holds the x-coordinate of the initial touch event for tap and hold.

0
initialTouchY: number

Holds the y-coordinate of the initial touch event for tap and hold.

0
intersects: ((state: CellState, x: number, y: number) => boolean)

Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.

Type declaration

    • (state, x, y): boolean
    • Parameters

      • state: CellState

        CellState that represents the cell state.

      • x: number

        X-coordinate of the location to be checked.

      • y: number

        Y-coordinate of the location to be checked.

      Returns boolean

invokesStopCellEditing: boolean

If true, when editing is to be stopped by way of selection changing, data in diagram changing or other means stopCellEditing is invoked, and changes are saved. This is implemented in a focus handler in CellEditorHandler.

true
isAllowAutoPanning: (() => boolean)
isAllowDanglingEdges: (() => boolean)

Returns allowDanglingEdges as a boolean.

isAllowNegativeCoordinates: (() => boolean)
isAutoExtend: (() => boolean)
isAutoScroll: (() => boolean)
isAutoSizeCell: ((cell: Cell) => boolean)

Returns true if the size of the given cell should automatically be updated after a change of the label.

This implementation returns autoSizeCells or checks if the cell style does specify CellStateStyle.autoSize to be true.

Type declaration

    • (cell): boolean
    • Parameters

      Returns boolean

isAutoSizeCells: (() => boolean)

Returns autoSizeCells.

isCellBendable: ((cell: Cell) => boolean)

Returns true if the given cell is bendable.

This returns cellsBendable for all given cells if cellsLocked does not return true for the given cell and its style does not specify CellStateStyle.bendable to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose bendable state should be returned.

      Returns boolean

isCellCloneable: ((cell: Cell) => boolean)

Returns true if the given cell is cloneable.

This implementation returns isCellsCloneable for all cells unless a cell style specifies CellStateStyle.cloneable to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Optional Cell whose cloneable state should be returned.

      Returns boolean

isCellDeletable: ((cell: Cell) => boolean)

Returns true if the given cell is deletable.

Type declaration

isCellDisconnectable: ((cell: Cell, terminal: null | Cell, source: boolean) => boolean)

Returns true if the given cell is disconnectable from the source or target terminal. This returns isCellsDisconnectable for all given cells if isCellLocked does not return true for the given cell.

Type declaration

    • (cell, terminal, source): boolean
    • Parameters

      • cell: Cell

        mxCell whose disconnectable state should be returned.

      • terminal: null | Cell

        mxCell that represents the source or target terminal.

      • source: boolean

        Boolean indicating if the source or target terminal is to be disconnected.

      Returns boolean

isCellEditable: ((cell: Cell) => boolean)

Returns true if the given cell is editable.

This returns cellsEditable for all given cells if isCellLocked does not return true for the given cell and its style does not specify CellStateStyle.editable to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose editable state should be returned.

      Returns boolean

isCellFoldable: ((cell: Cell, collapse: boolean) => boolean)

Returns true if the given cell is foldable.

The default implementation returns true if the cell has at least one child and its style does not specify CellStyle.foldable to be false.

Type declaration

    • (cell, collapse): boolean
    • Parameters

      • cell: Cell

        whose foldable state should be returned.

      • collapse: boolean

      Returns boolean

isCellLocked: ((cell: Cell) => boolean)

Returns true if the given cell may not be moved, sized, bended, disconnected, edited or selected.

This implementation returns true for all vertices with a relative geometry if locked is false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose locked state should be returned.

      Returns boolean

isCellMovable: ((cell: Cell) => boolean)

Returns true if the given cell is movable.

This returns cellsMovable for all given cells if isCellLocked does not return true for the given cell, and its style does not specify CellStateStyle.movable to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose movable state should be returned.

      Returns boolean

isCellResizable: ((cell: Cell) => boolean)

Returns true if the given cell is resizable.

This returns cellsResizable for all given cells if isCellLocked does not return true for the given cell and its style does not specify 'resizable' to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose resizable state should be returned.

      Returns boolean

isCellRotatable: ((cell: Cell) => boolean)

Returns true if the given cell is rotatable.

This returns true for the given cell if its style does not specify CellStateStyle.rotatable to be false.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose rotatable state should be returned.

      Returns boolean

isCellsBendable: (() => boolean)

Returns cellsBendable.

isCellsCloneable: (() => boolean)

Returns cellsCloneable, that is, if the graph allows cloning of cells by using control-drag.

isCellsDeletable: (() => boolean)

Returns cellsDeletable.

isCellsDisconnectable: (() => boolean)
isCellsEditable: (() => boolean)

Returns cellsEditable.

isCellSelectable: ((cell: Cell) => boolean)

Returns true if the given cell is selectable.

This implementation returns cellsSelectable.

To add a new style for making cells (un)selectable, use the following code.

isCellSelectable(cell)
{
var style = this.getCurrentCellStyle(cell);

return this.isCellsSelectable() && !this.isCellLocked(cell) && style.selectable != 0;
};

You can then use the new style as shown in this example.

graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30, 'selectable=0');

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose selectable state should be returned.

      Returns boolean

isCellSelected: ((cell: Cell) => boolean)

Returns true if the given cell is selected.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell for which the selection state should be returned.

      Returns boolean

isCellsLocked: (() => boolean)
isCellsMovable: (() => boolean)

Returns cellsMovable.

isCellsResizable: (() => boolean)

Returns cellsResizable.

isCellsSelectable: (() => boolean)

Returns cellsSelectable.

isCloneEvent: ((evt: MouseEvent) => boolean)

Returns true if the given event is a clone event.

This implementation returns true if control is pressed.

isCloneInvalidEdges: (() => boolean)

Returns cloneInvalidEdges as a boolean.

isConnectable: (() => boolean)

Returns true if the ConnectionHandler is enabled.

isConnectableEdges: (() => boolean)

Returns connectableEdges as a boolean.

isConstrainChild: ((cell: Cell) => boolean)

Returns true if the given cell should be kept inside the bounds of its parent according to the rules defined by getOverlap and isAllowOverlapParent.

This implementation returns false for all children of edges and isConstrainChildren otherwise.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell that should be constrained.

      Returns boolean

isConstrainChildren: (() => boolean)
isConstrainedEvent: ((evt: MouseEvent) => boolean)

Returns true if the given mouse event should be aligned to the grid.

isConstrainedMoving: boolean = false
isConstrainRelativeChildren: (() => boolean)
isDisconnectOnMove: (() => boolean)

Returns disconnectOnMove as a boolean.

isDropEnabled: (() => boolean)

Returns dropEnabled as a boolean.

isEdgeLabelsMovable: (() => boolean)
isEdgeValid: ((edge: null | Cell, source: Cell, target: Cell) => boolean)

Checks if the return value of getEdgeValidationError for the given arguments is null.

Type declaration

    • (edge, source, target): boolean
    • Parameters

      • edge: null | Cell

        Cell that represents the edge to validate.

      • source: Cell

        Cell that represents the source terminal.

      • target: Cell

        Cell that represents the target terminal.

      Returns boolean

isEditing: ((cell?: null | Cell) => boolean)

Returns true if the given cell is currently being edited.

If no cell is specified, then this returns true if any cell is currently being edited.

Type declaration

    • (cell?): boolean
    • Parameters

      • Optionalcell: null | Cell

        Cell that should be checked.

      Returns boolean

isEnterStopsCellEditing: (() => boolean)
isEscapeEnabled: (() => boolean)

Returns escapeEnabled.

isEventIgnored: ((evtName: string, me: InternalMouseEvent, sender: EventSource) => boolean)

Returns true if the event should be ignored in fireMouseEvent.

isEventSourceIgnored: ((evtName: string, me: InternalMouseEvent) => boolean)

Returns true if the event should be ignored in fireMouseEvent.

This implementation returns true for select, option and input (if not of type checkbox, radio, button, submit or file) event sources if the event is not a mouse event or a left mouse button press event.

Type declaration

isExtendParent: ((cell: Cell) => boolean)

Returns true if the parent of the given cell should be extended if the child has been resized so that it overlaps the parent.

This implementation returns isExtendParents if the cell is not an edge.

Type declaration

    • (cell): boolean
    • Parameters

      Returns boolean

isExtendParents: (() => boolean)

Returns extendParents.

isExtendParentsOnAdd: ((cell: Cell) => boolean)
isExtendParentsOnMove: (() => boolean)
isFoldingEnabled: (() => boolean)
isGridEnabled: (() => boolean)

Returns gridEnabled.

isGridEnabledEvent: ((evt: MouseEvent) => boolean)

Returns true if the given mouse event should be aligned to the grid.

isHtmlLabel: ((cell: Cell) => boolean)

Returns true if the label must be rendered as HTML markup.

The default implementation returns htmlLabels.

isHtmlLabels: (() => boolean)

Returns htmlLabels.

isIgnoreTerminalEvent: ((evt: MouseEvent) => boolean)

Returns true if the given mouse event should not allow any connections to be made.

This implementation returns false.

isInvokesStopCellEditing: (() => boolean)
isLabelClipped: ((cell: Cell) => boolean)

Returns true if the overflow portion of labels should be hidden.

If this returns true then vertex labels will be clipped to the size of the vertices.

This implementation returns true if overflow in the style of the given cell is 'hidden'.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose label should be clipped.

      Returns boolean

isLabelMovable: ((cell: Cell) => boolean)

Returns true if the given edges' label is moveable.

This returns movable for all given cells if isCellLocked does not return true for the given cell.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose label should be moved.

      Returns boolean

isLabelsVisible: (() => boolean)
isMouseDown: boolean

Holds the state of the mouse button.

false
isMouseTrigger: null | boolean
isNativeDblClickEnabled: (() => boolean)
isPort: ((cell: null | Cell) => boolean)

Returns true if the given cell is a "port", that is, when connecting to it, the cell returned by getTerminalForPort should be used as the terminal and the port should be referenced by the ID in either the CellStateStyle.sourcePort or the CellStateStyle.sourcePort.

Note that a port should not be movable.

This implementation always returns false.

A typical implementation is the following:

graph.isPort = function(cell) {
const geo = cell.getGeometry();

return (geo != null) ? geo.relative : false;
};

Type declaration

    • (cell): boolean
    • Parameters

      • cell: null | Cell

        Cell that represents the port.

      Returns boolean

isPortsEnabled: (() => boolean)

Returns portsEnabled.

isResetEdgesOnConnect: (() => boolean)
isResetEdgesOnMove: (() => boolean)
isResetEdgesOnResize: (() => boolean)
isSelectionEmpty: (() => boolean)

Returns true if the selection is empty.

isSiblingSelected: ((cell: Cell) => boolean)

Returns true if any sibling of the given cell is selected.

isSplitEnabled: (() => boolean)

Returns splitEnabled as a boolean.

isSplitTarget: ((target: Cell, cells?: Cell[], evt?: null | MouseEvent) => boolean)

Returns true if the given edge may be split into two edges with the given cell as a new terminal between the two.

Type declaration

    • (target, cells?, evt?): boolean
    • Parameters

      • target: Cell

        Cell that represents the edge to be split.

      • Optionalcells: Cell[]

        Cell that should split the edge.

      • Optionalevt: null | MouseEvent

        MouseEvent that triggered the invocation.

      Returns boolean

isSwimlane: ((cell: Cell, ignoreState?: boolean) => boolean)

Returns true if the given cell is a swimlane in the graph. A swimlane is a container cell with some specific behaviour. This implementation checks if the shape associated with the given cell is a SwimlaneShape.

Type declaration

    • (cell, ignoreState?): boolean
    • Parameters

      • cell: Cell

        Cell to be checked.

      • OptionalignoreState: boolean

        Optional boolean that specifies if the cell state should be ignored.

      Returns boolean

isSwimlaneNesting: (() => boolean)

Returns swimlaneNesting as a boolean.

isSwimlaneSelectionEnabled: (() => boolean)

Returns swimlaneSelectionEnabled as a boolean.

isSyntheticEventIgnored: ((evtName: string, me: InternalMouseEvent, sender: any) => boolean)

Hook for ignoring synthetic mouse events after touchend in Firefox.

isTerminalPointMovable: ((cell: Cell, source: boolean) => boolean)

Returns true if the given terminal point is movable. This is independent from isCellConnectable and isCellDisconnectable and controls if terminal points can be moved in the graph if the edge is not connected. Note that it is required for this to return true to connect unconnected edges.

This implementation returns true.

Type declaration

    • (cell, source): boolean
    • Parameters

      • cell: Cell

        Cell whose terminal point should be moved.

      • source: boolean

        Boolean indicating if the source or target terminal should be moved.

      Returns boolean

isTimerAutoScroll: (() => boolean)
isToggleEvent: ((evt: MouseEvent) => boolean)

Returns true if the given event is a toggle event.

This implementation returns true if the meta key (Cmd) is pressed on Macs or if control is pressed on any other platform.

isTransparentClickEvent: ((evt: MouseEvent) => boolean)

Hook for implementing click-through behaviour on selected cells. If this method returns true the cell behind the selected cell will be selected.

This implementation returns false.

isUseScrollbarsForPanning: (() => boolean)
isValidAncestor: ((cell: Cell, parent: Cell, recurse: boolean) => boolean)

Returns whether the specified parent is a valid ancestor of the specified cell, either direct or indirectly based on whether ancestor recursion is enabled.

Type declaration

    • (cell, parent, recurse): boolean
    • Parameters

      • cell: Cell

        Cell the possible child cell

      • parent: Cell

        Cell the possible parent cell

      • recurse: boolean

        boolean whether to recurse the child ancestors. Default is false.

      Returns boolean

isValidConnection: ((source: null | Cell, target: null | Cell) => boolean)

Returns true if the given target cell is a valid target for source.

This is a boolean implementation for not allowing connections between certain pairs of vertices and is called by getEdgeValidationError.

This implementation returns true if isValidSource returns true for the source and isValidTarget returns true for the target.

Type declaration

    • (source, target): boolean
    • Parameters

      • source: null | Cell

        Cell that represents the source cell.

      • target: null | Cell

        Cell that represents the target cell.

      Returns boolean

isValidDropTarget: ((cell: Cell, cells?: Cell[], evt?: null | MouseEvent) => boolean)

Returns true if the given cell is a valid drop target for the specified cells.

If splitEnabled is true then this returns isSplitTarget for the given arguments else it returns true if the cell is not collapsed and its child count is greater than 0.

Type declaration

    • (cell, cells?, evt?): boolean
    • Parameters

      • cell: Cell

        Cell that represents the possible drop target.

      • Optionalcells: Cell[]

        Cell that should be dropped into the target.

      • Optionalevt: null | MouseEvent

        Mouseevent that triggered the invocation.

      Returns boolean

isValidSource: ((cell: null | Cell) => boolean)

Returns true if the given cell is a valid source for new connections.

This implementation returns true for all non-null values and is called by is called by isValidConnection.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: null | Cell

        mxCell that represents a possible source or null.

      Returns boolean

isValidTarget: ((cell: null | Cell) => boolean)

Returns isValidSource for the given cell. This is called by isValidConnection.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: null | Cell

        mxCell that represents a possible target or null.

      Returns boolean

isVertexLabelsMovable: (() => boolean)
isWrapping: ((cell: Cell) => boolean)

This enables wrapping for HTML labels.

Returns true if no white-space CSS style directive should be used for displaying the given cells label.

This implementation returns true if 'whiteSpace' in the style of the given cell is 'wrap'.

This is used as a workaround for IE ignoring the white-space directive of child elements if the directive appears in a parent element. It should be overridden to return true if a white-space directive is used in the HTML markup that represents the given cells label. In order for HTML markup to work in labels, isHtmlLabel must also return true for the given cell.

Type declaration

    • (cell): boolean
    • Parameters

      • cell: Cell

        Cell whose label should be wrapped.

      Returns boolean

const getLabel = graph.getLabel;
graph.getLabel = function(cell) {
const tmp = getLabel.apply(this, arguments); // "supercall"

if (this.model.isEdge(cell)) {
tmp = '<div style="width: 150px; white-space:normal;">'+tmp+'</div>';
}

return tmp;
}

graph.isWrapping = function(state) {
return this.model.isEdge(state.cell);
}

Makes sure no edge label is wider than 150 pixels, otherwise the content is wrapped. Note: No width must be specified for wrapped vertex labels as the vertex defines the width in its geometry.

keepEdgesInBackground: boolean = false

Specifies if edges should appear in the background regardless of their order in the model. If keepEdgesInForeground and keepEdgesInBackground are both true then the normal order is applied.

false
keepEdgesInForeground: boolean = false

Specifies if edges should appear in the foreground regardless of their order in the model. If keepEdgesInForeground and keepEdgesInBackground are both true then the normal order is applied.

false
keepSelectionVisibleOnZoom: boolean

Specifies if the viewport should automatically contain the selection cells after a zoom operation.

false
labelChanged: ((cell: Cell, value: any, evt: EventObject | InternalMouseEvent) => Cell)

Sets the label of the specified cell to the given value using cellLabelChanged and fires InternalEvent.LABEL_CHANGED while the transaction is in progress.

Type declaration

    • (cell, value, evt): Cell
    • Parameters

      Returns Cell

      The cell whose label was changed.

labelsVisible: boolean

Specifies if labels should be visible. This is used in getLabel.

true
lastEvent: any
lastMouseX: null | number
lastMouseY: null | number
lastTouchCell: null | Cell
lastTouchEvent: null | MouseEvent
lastTouchTime: number

Holds the time of the last touch event for double click detection.

0
lastTouchX: number

Holds the x-coordinate of the last touch event for double tap detection.

0
lastTouchY: number

Holds the x-coordinate of the last touch event for double tap detection.

0
maxFitScale: number = 8

Specifies the maximum scale to be applied in fit. Set this to null to allow any value.

8
maximumContainerSize: null | Rectangle = null

Rectangle that specifies the maximum size of the container if resizeContainer is true.

maximumGraphBounds: null | Rectangle = null

Rectangle that specifies the area in which all cells in the diagram should be placed. Uses in getMaximumGraphBounds. Use a width or height of 0 if you only want to give a upper, left corner.

minFitScale: number = 0.1

Specifies the minimum scale to be applied in fit. Set this to null to allow any value.

0.1
minimumContainerSize: null | Rectangle = null

Rectangle that specifies the minimum size of the container if resizeContainer is true.

minimumGraphSize: null | Rectangle = null

Rectangle that specifies the minimum size of the graph. This is ignored if the graph container has no scrollbars.

null
minPageBreakDist: number = 20

Specifies the minimum distance in pixels for page breaks to be visible.

20

Holds the GraphDataModel that contains the cells to be displayed.

mouseListeners: MouseListenerSet[] = []

Holds the mouse event listeners. See fireMouseEvent.

mouseMoveRedirect: null | MouseEventListener
mouseUpRedirect: null | MouseEventListener
moveCells: ((cells: Cell[], dx?: number, dy?: number, clone?: boolean, target?: null | Cell, evt?: null | MouseEvent, mapping?: any) => Cell[])

Moves or clones the specified cells and moves the cells or clones by the given amount, adding them to the optional target cell. The evt is the mouse event as the mouse was released. The change is carried out using cellsMoved. This method fires Event#MOVE_CELLS while the transaction is in progress.

Use the following code to move all cells in the graph.

graph.moveCells(graph.getChildCells(null, true, true), 10, 10);

Type declaration

    • (cells, dx?, dy?, clone?, target?, evt?, mapping?): Cell[]
    • Parameters

      • cells: Cell[]

        Array of Cell to be moved, cloned or added to the target.

      • Optionaldx: number

        Integer that specifies the x-coordinate of the vector. Default is 0.

      • Optionaldy: number

        Integer that specifies the y-coordinate of the vector. Default is 0.

      • Optionalclone: boolean

        Boolean indicating if the cells should be cloned. Default is false.

      • Optionaltarget: null | Cell

        Cell that represents the new parent of the cells.

      • Optionalevt: null | MouseEvent

        MouseEvent that triggered the invocation.

      • Optionalmapping: any

        Optional mapping for existing clones.

      Returns Cell[]

      the cells that were moved.

multigraph: boolean = true

Specifies if multiple edges in the same direction between the same pair of vertices are allowed.

true
multiplicities: Multiplicity[] = []

An array of Multiplicity describing the allowed connections in a graph.

nativeDblClickEnabled: boolean

Specifies if native double click events should be detected.

true
options: GraphFoldingOptions

Folding options.

orderCells: ((back: boolean, cells?: Cell[]) => Cell[])

Moves the given cells to the front or back. The change is carried out using cellsOrdered.

This method fires InternalEvent.ORDER_CELLS while the transaction is in progress.

Type declaration

    • (back, cells?): Cell[]
    • Parameters

      • back: boolean

        Boolean that specifies if the cells should be moved to back. Default is false.

      • Optionalcells: Cell[]

        Array of Cell to move to the background. If not set, then the selection cells are used.

      Returns Cell[]

pageBreakColor: string = 'gray'

Specifies the color for page breaks.

gray
pageBreakDashed: boolean = true

Specifies the page breaks should be dashed.

true
pageBreaksVisible: boolean = false

Specifies if a dashed line should be drawn between multiple pages. If you change this value while a graph is being displayed then you should call sizeDidChange to force an update of the display.

false
pageFormat: Rectangle = ...

Specifies the page format for the background page. This is used as the default in PrintPreview and for painting the background page if pageVisible is true and the page breaks if pageBreaksVisible is true.

mxConstants.PAGE_FORMAT_A4_PORTRAIT

pageScale: number = 1.5

Specifies the scale of the background page. Not yet implemented.

1.5
pageVisible: boolean = false

Specifies if the background page should be visible. Not yet implemented.

false
paintBackground: null | Function = null
panDx: number

Current horizontal panning value.

0
panDy: number

Current vertical panning value.

0
panGraph: ((dx: number, dy: number) => void)

Shifts the graph display by the given amount. This is used to preview panning operations, use GraphView.setTranslate to set a persistent translation of the view.

Fires InternalEvent.PAN.

Type declaration

    • (dx, dy): void
    • Parameters

      • dx: number

        Amount to shift the graph along the x-axis.

      • dy: number

        Amount to shift the graph along the y-axis.

      Returns void

portsEnabled: boolean

Specifies if ports are enabled. This is used in cellConnected to update the respective style.

true
postProcessCellStyle: ((style: CellStateStyle) => CellStateStyle)

Tries to resolve the value for the image style in the image bundles and turns short data URIs as defined in ImageBundle to data URIs as defined in RFC 2397 of the IETF.

preferPageSize: boolean = false

Specifies if the graph size should be rounded to the next page number in sizeDidChange. This is only used if the graph container has scrollbars.

false
recursiveResize: boolean = false

Specifies the return value for isRecursiveResize.

false (for backwards compatibility)
removeCellOverlay: ((cell: Cell, overlay: null | CellOverlay) => null | CellOverlay)

Removes and returns the given CellOverlay from the given cell.

This method fires a InternalEvent.REMOVE_OVERLAY event.

If no overlay is given, then all overlays are removed using removeCellOverlays.

Type declaration

removeCellOverlays: ((cell: Cell) => CellOverlay[])

Removes all CellOverlays from the given cell.

This method fires a InternalEvent.REMOVE_OVERLAY event for each CellOverlay and returns an array of CellOverlays that was removed from the cell.

Type declaration

removeCells: ((cells?: null | Cell[], includeEdges?: null | boolean) => Cell[])

Removes the given cells from the graph including all connected edges if includeEdges is true. The change is carried out using cellsRemoved. This method fires InternalEvent.REMOVE_CELLS while the transaction is in progress. The removed cells are returned as an array.

Type declaration

    • (cells?, includeEdges?): Cell[]
    • Parameters

      • Optionalcells: null | Cell[]

        Array of Cell to remove. If null is specified then the selection cells which are deletable are used.

      • OptionalincludeEdges: null | boolean

        Optional boolean which specifies if all connected edges should be removed as well. Default is true.

      Returns Cell[]

removeCellsAfterUngroup: ((cells: Cell[]) => void)

Hook to remove the groups after ungroupCells.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell that were ungrouped.

      Returns void

removeCellsFromParent: ((cells?: null | Cell[]) => Cell[])

Removes the specified cells from their parents and adds them to the default parent.

Type declaration

    • (cells?): Cell[]
    • Parameters

      • Optionalcells: null | Cell[]

        Array of Cell to be removed from their parents.

      Returns Cell[]

      the cells that were removed from their parents.

removeImageBundle: ((bundle: ImageBundle) => void)

Removes the specified ImageBundle.

removeMouseListener: ((listener: MouseListenerSet) => void)

Removes the specified graph listener.

Type declaration

    • (listener): void
    • Parameters

      • listener: MouseListenerSet

        Listener to be removed from the graph event listeners.

      Returns void

removeSelectionCell: ((cell: Cell) => void)

Removes the given cell from the selection.

Type declaration

    • (cell): void
    • Parameters

      • cell: Cell

        Cell to be removed from the selection.

      Returns void

removeSelectionCells: ((cells: Cell[]) => void)

Removes the given cells from the selection.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell to be removed from the selection.

      Returns void

removeStateForCell: ((cell: Cell) => void)

Removes all cached information for the given cell and its descendants. This is called when a cell was removed from the model.

Type declaration

    • (cell): void
    • Parameters

      • cell: Cell

        Cell that was removed from the model.

      Returns void

renderHint: null | string = null

RenderHint as it was passed to the constructor.

resetEdge: ((edge: Cell) => Cell)

Resets the control points of the given edge.

Type declaration

    • (edge): Cell
    • Parameters

      • edge: Cell

        mxCell whose points should be reset.

      Returns Cell

resetEdges: ((cells: Cell[]) => void)

Resets the control points of the edges that are connected to the given cells if not both ends of the edge are in the given cells array.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell for which the connected edges should be reset.

      Returns void

resetEdgesOnConnect: boolean

Specifies if edge control points should be reset after the edge has been reconnected.

true
resetEdgesOnMove: boolean

Specifies if edge control points should be reset after the move of a connected cell.

false
resetEdgesOnResize: boolean

Specifies if edge control points should be reset after the resize of a connected cell.

false
resetViewOnRootChange: boolean = true

Specifies if the scale and translate should be reset if the root changes in the model.

true
resizeCell: ((cell: Cell, bounds: Rectangle, recurse?: boolean) => Cell)

Sets the bounds of the given cell using resizeCells. Returns the cell which was passed to the function.

Type declaration

    • (cell, bounds, recurse?): Cell
    • Parameters

      • cell: Cell

        Cell whose bounds should be changed.

      • bounds: Rectangle

        Rectangle that represents the new bounds.

      • Optionalrecurse: boolean

        Optional boolean that specifies if the children should be resized. Default is false.

      Returns Cell

resizeCells: ((cells: Cell[], bounds: Rectangle[], recurse: boolean) => Cell[])

Sets the bounds of the given cells and fires a InternalEvent.RESIZE_CELLS event while the transaction is in progress. Returns the cells which have been passed to the function.

Type declaration

    • (cells, bounds, recurse): Cell[]
    • Parameters

      • cells: Cell[]

        Array of Cell whose bounds should be changed.

      • bounds: Rectangle[]

        Array of Rectangles that represent the new bounds.

      • recurse: boolean

        Optional boolean that specifies if the children should be resized. Default is isRecursiveResize.

      Returns Cell[]

resizeChildCells: ((cell: Cell, newGeo: Geometry) => void)

Resizes the child cells of the given cell for the given new geometry with respect to the current geometry of the cell.

Type declaration

    • (cell, newGeo): void
    • Parameters

      Returns void

resizeContainer: boolean = false

Specifies if the container should be resized to the graph size when the graph size has changed.

false
scaleCell: ((cell: Cell, dx: number, dy: number, recurse: boolean) => void)

Scales the points, position and size of the given cell according to the given vertical and horizontal scaling factors.

Type declaration

    • (cell, dx, dy, recurse): void
    • Parameters

      • cell: Cell

        Cell whose geometry should be scaled.

      • dx: number

        Horizontal scaling factor.

      • dy: number

        Vertical scaling factor.

      • recurse: boolean

        Boolean indicating if the child cells should be scaled. Default is false.

      Returns void

scrollCellToVisible: ((cell: Cell, center?: boolean) => void)

Pans the graph so that it shows the given cell. Optionally the cell may be centered in the container.

To center a given graph if the container has no scrollbars, use the following code.

const bounds = graph.getGraphBounds();
graph.view.setTranslate(-bounds.x - (bounds.width - container.clientWidth) / 2,
-bounds.y - (bounds.height - container.clientHeight) / 2);

Type declaration

    • (cell, center?): void
    • Parameters

      • cell: Cell

        Cell to be made visible.

      • Optionalcenter: boolean

        Optional boolean flag. Default is false.

      Returns void

scrollRectToVisible: ((rect: Rectangle) => boolean)

Pans the graph so that it shows the given rectangle.

Type declaration

selectAll: ((parent?: null | Cell, descendants?: boolean) => void)

Selects all children of the given parent cell or the children of the default parent if no parent is specified.

To select leaf vertices and/or edges use selectCells.

Type declaration

    • (parent?, descendants?): void
    • Parameters

      • Optionalparent: null | Cell

        Optional Cell whose children should be selected. Default is defaultParent.

      • Optionaldescendants: boolean

        Optional boolean specifying whether all descendants should be selected. Default is false.

      Returns void

selectCell: ((isNext?: boolean, isParent?: boolean, isChild?: boolean) => void)

Selects the next, parent, first child or previous cell, if all arguments are false.

Type declaration

    • (isNext?, isParent?, isChild?): void
    • Parameters

      • OptionalisNext: boolean

        Boolean indicating if the next cell should be selected. Default is false.

      • OptionalisParent: boolean

        Boolean indicating if the parent cell should be selected. Default is false.

      • OptionalisChild: boolean

        Boolean indicating if the first child cell should be selected. Default is false.

      Returns void

selectCellForEvent: ((cell: Cell, evt: MouseEvent) => void)

Selects the given cell by either adding it to the selection or replacing the selection depending on whether the given mouse event is a toggle event.

Type declaration

    • (cell, evt): void
    • Parameters

      • cell: Cell

        Cell to be selected.

      • evt: MouseEvent

        Optional mouseEvent that triggered the selection.

      Returns void

selectCells: ((vertices: boolean, edges: boolean, parent?: null | Cell, selectGroups?: boolean) => void)

Selects all vertices and/or edges depending on the given boolean arguments recursively, starting at the given parent or the default parent if no parent is specified.

Use selectAll to select all cells.

For vertices, only cells with no children are selected.

Type declaration

    • (vertices, edges, parent?, selectGroups?): void
    • Parameters

      • vertices: boolean

        Boolean indicating if vertices should be selected.

      • edges: boolean

        Boolean indicating if edges should be selected.

      • Optionalparent: null | Cell

        Optional Cell that acts as the root of the recursion. Default is defaultParent.

      • OptionalselectGroups: boolean

        Optional boolean that specifies if groups should be selected. Default is false.

      Returns void

selectCellsForEvent: ((cells: Cell[], evt: MouseEvent) => void)

Selects the given cells by either adding them to the selection or replacing the selection depending on whether the given mouse event is a toggle event.

Type declaration

    • (cells, evt): void
    • Parameters

      • cells: Cell[]

        Array of Cell to be selected.

      • evt: MouseEvent

        Optional mouseEvent that triggered the selection.

      Returns void

selectChildCell: (() => void)

Selects the first child cell.

selectEdges: ((parent?: null | Cell) => void)

Select all edges inside the given parent or the default parent.

selectionModel: any
null
selectNextCell: (() => void)

Selects the next cell.

selectParentCell: (() => void)

Selects the parent cell.

selectPreviousCell: (() => void)

Selects the previous cell.

selectRegion: ((rect: Rectangle, evt: MouseEvent) => Cell[])

Selects and returns the cells inside the given rectangle for the specified event.

Type declaration

    • (rect, evt): Cell[]
    • Parameters

      • rect: Rectangle

        Rectangle that represents the region to be selected.

      • evt: MouseEvent

        MouseEvent that triggered the selection.

      Returns Cell[]

selectVertices: ((parent?: null | Cell, selectGroups?: boolean) => void)

Select all vertices inside the given parent or the default parent.

setAllowDanglingEdges: ((value: boolean) => void)

Specifies if dangling edges are allowed, that is, if edges are allowed that do not have a source and/or target terminal defined.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if dangling edges are allowed.

      Returns void

setAllowNegativeCoordinates: ((value: boolean) => void)
setAutoSizeCells: ((value: boolean) => void)

Specifies if cell sizes should be automatically updated after a label change.

This implementation sets autoSizeCells to the given parameter.

To update the size of cells when the cells are added, set autoSizeCellsOnAdd to true.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if cells should be resized automatically.

      Returns void

setCellsBendable: ((value: boolean) => void)

Specifies if the graph should allow bending of edges.

This implementation updates cellsBendable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow bending of edges.

      Returns void

setCellsCloneable: ((value: boolean) => void)

Specifies if the graph should allow cloning of cells by holding down the control key while cells are being moved.

This implementation updates cellsCloneable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should be cloneable.

      Returns void

setCellsDeletable: ((value: boolean) => void)

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow deletion of cells.

      Returns void

setCellsDisconnectable: ((value: boolean) => void)
setCellsEditable: ((value: boolean) => void)

Specifies if the graph should allow in-place editing for cell labels.

This implementation updates cellsEditable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow in-place editing.

      Returns void

setCellsLocked: ((value: boolean) => void)

Sets if any cell may be moved, sized, bended, disconnected, edited or selected.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean that defines the new value for cellsLocked.

      Returns void

setCellsMovable: ((value: boolean) => void)

Specifies if the graph should allow moving of cells.

This implementation updates cellsMovable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow moving of cells.

      Returns void

setCellsResizable: ((value: boolean) => void)

Specifies if the graph should allow resizing of cells. This implementation updates cellsResizable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow resizing of cells.

      Returns void

setCellsSelectable: ((value: boolean) => void)
setCellStyle: ((style: CellStyle, cells?: Cell[]) => void)

Sets the style of the specified cells. If no cells are given, then the selection cells are changed.

IMPORTANT: Do not pass Cell.getStyle as value of the style parameter. Always get a clone of the style of the cell with Cell.getClonedStyle, then update it and pass the updated style to this method. For more details, see GraphDataModel.setStyle.

Type declaration

    • (style, cells?): void
    • Parameters

      • style: CellStyle

        String representing the new style of the cells.

      • Optionalcells: Cell[]

        Optional array of Cell to set the style for. Default is the selection cells.

      Returns void

setCellStyleFlags: ((key: NumericCellStateStyleKeys, flag: number, value?: null | boolean, cells?: null | Cell[]) => void)

Sets or toggles the given bit for the given key in the styles of the specified cells.

Type declaration

    • (key, flag, value?, cells?): void
    • Parameters

      • key: NumericCellStateStyleKeys

        String representing the key to toggle the flag in.

      • flag: number

        Integer that represents the bit to be toggled.

      • Optionalvalue: null | boolean

        Boolean value to be used or null if the value should be toggled. Default is null.

      • Optionalcells: null | Cell[]

        Optional array of Cell to change the style for. Default is the selection cells.

      Returns void

setCellStyles: ((key: keyof CellStateStyle, value:
    | undefined
    | null
    | string
    | number
    | boolean
    | string & {}
    | EdgeStyleFunction
    | PerimeterFunction, cells?: Cell[]) => void)

Sets the key to value in the styles of the given cells. This will modify the existing cell styles in-place and override any existing assignment for the given key.

If no cells are specified, then the selection cells are changed.

If no value is specified, then the respective key is removed from the styles.

Type declaration

    • (key, value, cells?): void
    • Parameters

      • key: keyof CellStateStyle

        String representing the key to be assigned.

      • value:
            | undefined
            | null
            | string
            | number
            | boolean
            | string & {}
            | EdgeStyleFunction
            | PerimeterFunction

        String representing the new value for the key.

      • Optionalcells: Cell[]

        Optional array of Cell to change the style for. Default is the selection cells.

      Returns void

setCellWarning: ((cell: Cell, warning: null | string, img?: ImageBox, isSelect?: boolean) => null | CellOverlay)

Creates an overlay for the given cell using the warning and image or warningImage and returns the new CellOverlay. The warning is displayed as a tooltip in a red font and may contain HTML markup. If the warning is null or a zero length string, then all overlays are removed from the cell.

Type declaration

    • (cell, warning, img?, isSelect?): null | CellOverlay
    • Parameters

      • cell: Cell

        Cell whose warning should be set.

      • warning: null | string

        String that represents the warning to be displayed.

      • Optionalimg: ImageBox

        Optional Image to be used for the overlay. Default is warningImage.

      • OptionalisSelect: boolean

        Optional boolean indicating if a click on the overlay should select the corresponding cell. Default is false.

      Returns null | CellOverlay

graph.setCellWarning(cell, '<b>Warning:</b>: Hello, World!');
setCloneInvalidEdges: ((value: boolean) => void)
setConnectable: ((connectable: boolean) => void)

Specifies if the graph should allow new connections.

This implementation updates ConnectionHandler.enabled.

Type declaration

    • (connectable): void
    • Parameters

      • connectable: boolean

        Boolean indicating if new connections should be allowed.

      Returns void

setConnectableEdges: ((value: boolean) => void)

Specifies if edges should be connectable.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if edges should be connectable.

      Returns void

setConnectionConstraint: ((edge: Cell, terminal: null | Cell, source: boolean, constraint: null | ConnectionConstraint) => void)

Sets the ConnectionConstraint that describes the given connection point. If no constraint is given then nothing is changed.

To remove an existing constraint from the given edge, use an empty constraint instead.

Type declaration

    • (edge, terminal, source, constraint): void
    • Parameters

      • edge: Cell

        Cell that represents the edge.

      • terminal: null | Cell

        Cell that represents the terminal.

      • source: boolean

        Boolean indicating if the terminal is the source or target. Default is false.

      • constraint: null | ConnectionConstraint

        Optional ConnectionConstraint to be used for this connection.

      Returns void

setConstrainChildren: ((value: boolean) => void)
setConstrainRelativeChildren: ((value: boolean) => void)
setDisconnectOnMove: ((value: boolean) => void)

Specifies if edges should be disconnected when moved.

Note: cloned edges are always disconnected.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if edges should be disconnected when moved.

      Returns void

setDropEnabled: ((value: boolean) => void)

Specifies if the graph should allow dropping of cells onto or into other cells.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow dropping of cells into other cells.

      Returns void

setEdgeLabelsMovable: ((value: boolean) => void)
setEnterStopsCellEditing: ((value: boolean) => void)
setEscapeEnabled: ((value: boolean) => void)

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if escape should be enabled.

      Returns void

setEventTolerance: ((tolerance: number) => void)
setExtendParents: ((value: boolean) => void)

Type declaration

    • (value): void
    • Parameters

      Returns void

setExtendParentsOnAdd: ((value: boolean) => void)

Type declaration

    • (value): void
    • Parameters

      Returns void

setExtendParentsOnMove: ((value: boolean) => void)

Type declaration

    • (value): void
    • Parameters

      Returns void

setGridEnabled: ((value: boolean) => void)

Specifies if the grid should be enabled.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the grid should be enabled.

      Returns void

setGridSize: ((value: number) => void)

Sets gridSize.

setHtmlLabels: ((value: boolean) => void)

Sets htmlLabels.

setInvokesStopCellEditing: ((value: boolean) => void)
setPanDx: ((dx: number) => void)
setPanDy: ((dy: number) => void)
setPanning: ((enabled: boolean) => void)

Specifies if panning should be enabled. This implementation updates PanningHandler.panningEnabled.

IMPORTANT*: only has an effect if the PanningHandler plugin is available.

Type declaration

    • (enabled): void
    • Parameters

      • enabled: boolean

        Boolean indicating if panning should be enabled.

      Returns void

setPortsEnabled: ((value: boolean) => void)

Specifies if the ports should be enabled.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the ports should be enabled.

      Returns void

setSelectionCell: ((cell: null | Cell) => void)

Sets the selection cell.

Type declaration

    • (cell): void
    • Parameters

      Returns void

setSelectionCells: ((cells: Cell[]) => void)

Sets the selection cell.

Type declaration

    • (cells): void
    • Parameters

      • cells: Cell[]

        Array of Cell to be selected.

      Returns void

setSelectionModel: ((selectionModel: GraphSelectionModel) => void)

Sets the GraphSelectionModel that contains the selection.

setSplitEnabled: ((value: boolean) => void)

Specifies if the graph should allow dropping of cells onto or into other cells.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if the graph should allow dropping of cells into other cells.

      Returns void

setSwimlaneNesting: ((value: boolean) => void)

Specifies if swimlanes can be nested by drag and drop. This is only taken into account if dropEnabled is true.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if swimlanes can be nested.

      Returns void

setSwimlaneSelectionEnabled: ((value: boolean) => void)

Specifies if swimlanes should be selected if the mouse is released over their content area.

Type declaration

    • (value): void
    • Parameters

      • value: boolean

        Boolean indicating if swimlanes content areas should be selected when the mouse is released over them.

      Returns void

setTooltips: ((enabled: boolean) => void)

Specifies if tooltips should be enabled.

This implementation updates TooltipHandler.enabled.

IMPORTANT: only has an effect if the TooltipHandler plugin is available.

Type declaration

    • (enabled): void
    • Parameters

      • enabled: boolean

        Boolean indicating if tooltips should be enabled.

      Returns void

setVertexLabelsMovable: ((value: boolean) => void)
shiftPreview1: null | HTMLElement
null
shiftPreview2: null | HTMLElement
null
singleSelection: boolean
sizeDidChange: (() => void)

Called when the size of the graph has changed.

This implementation fires a size event after updating the clipping region of the SVG element in SVG-bases browsers.

snap: ((value: number) => number)

Snaps the given numeric value to the grid if gridEnabled is true.

Type declaration

    • (value): number
    • Parameters

      • value: number

        Numeric value to be snapped to the grid.

      Returns number

snapDelta: ((delta: Point, bounds: Rectangle, ignoreGrid?: boolean, ignoreHorizontal?: boolean, ignoreVertical?: boolean) => Point)

Snaps the given delta with the given scaled bounds.

Type declaration

    • (delta, bounds, ignoreGrid?, ignoreHorizontal?, ignoreVertical?): Point
    • Parameters

      • delta: Point
      • bounds: Rectangle
      • OptionalignoreGrid: boolean

        default false

      • OptionalignoreHorizontal: boolean

        default false

      • OptionalignoreVertical: boolean

        default false

      Returns Point

snapTolerance: number
0
splitEdge: ((edge: Cell, cells: Cell[], newEdge: null | Cell, dx?: number, dy?: number, x?: number, y?: number, parent?: null | Cell) => Cell)

Splits the given edge by adding the newEdge between the previous source and the given cell and reconnecting the source of the given edge to the given cell.

This method fires InternalEvent.SPLIT_EDGE while the transaction is in progress.

Type declaration

    • (edge, cells, newEdge, dx?, dy?, x?, y?, parent?): Cell
    • Parameters

      • edge: Cell

        Cell that represents the edge to be split.

      • cells: Cell[]

        Cells that represents the cells to insert into the edge.

      • newEdge: null | Cell

        that represents the edge to be inserted.

      • Optionaldx: number

        Optional integer that specifies the vector to move the cells.

      • Optionaldy: number

        Optional integer that specifies the vector to move the cells.

      • Optionalx: number

        Integer that specifies the x-coordinate of the drop location.

      • Optionaly: number

        Integer that specifies the y-coordinate of the drop location.

      • Optionalparent: null | Cell

        Optional parent to insert the cell. If null, the parent of the edge is used.

      Returns Cell

      The new edge that was inserted.

splitEnabled: boolean

Specifies if dropping onto edges should be enabled.

This is ignored if dropEnabled is false. If enabled, it will call splitEdge to carry out the drop operation.

true
startEditing: ((evt: MouseEvent) => void)

Calls startEditingAtCell using the given cell or the first selection cell.

Type declaration

    • (evt): void
    • Parameters

      • evt: MouseEvent

        Optional mouse event that triggered the editing.

      Returns void

startEditingAtCell: ((cell: null | Cell, evt?: null | MouseEvent) => void)

Fires a InternalEvent.START_EDITING event and invokes CellEditorHandler.startEditing. After editing was started, a InternalEvent.EDITING_STARTED event is fired.

Type declaration

    • (cell, evt?): void
    • Parameters

      • cell: null | Cell

        Cell to start the in-place editor for.

      • Optionalevt: null | MouseEvent

        Optional mouse event that triggered the editing.

      Returns void

stopEditing: ((cancel: boolean) => void)

Stops the current editing and fires a InternalEvent.EDITING_STOPPED event.

Type declaration

    • (cancel): void
    • Parameters

      • cancel: boolean

        Boolean that specifies if the current editing value should be stored.

      Returns void

stylesheet: Stylesheet

Holds the Stylesheet that defines the appearance of the cells.

Use the following code to read a stylesheet into an existing graph.

var req = mxUtils.load('stylesheet.xml');
var root = req.getDocumentElement();
var dec = new Codec(root.ownerDocument);
dec.decode(root, graph.stylesheet);
swapBounds: ((cell: Cell, willCollapse: boolean) => void)

Swaps the alternate and the actual bounds in the geometry of the given cell invoking updateAlternateBounds before carrying out the swap.

Type declaration

    • (cell, willCollapse): void
    • Parameters

      • cell: Cell

        Cell for which the bounds should be swapped.

      • willCollapse: boolean

        Boolean indicating if the cell is going to be collapsed. Default is false.

      Returns void

swimlaneIndicatorColorAttribute: string

The attribute used to find the color for the indicator if the indicator color is set to 'swimlane'.

'fillColor'

swimlaneNesting: boolean

Specifies if nesting of swimlanes is allowed.

true
swimlaneSelectionEnabled: boolean

Specifies if swimlanes should be selectable via the content if the mouse is released.

true
tapAndHold: ((me: InternalMouseEvent) => void)

Handles the InternalMouseEvent by highlighting the CellState.

Type declaration

    • (me): void
    • Parameters

      Returns void

tapAndHoldDelay: number

Specifies the time in milliseconds for a tap and hold.

500
tapAndHoldEnabled: boolean

Specifies if tap and hold should be used for starting connections on touch-based devices.

true
tapAndHoldInProgress: boolean

true if the timer for tap and hold events is running.

false
tapAndHoldThread: null | number
tapAndHoldValid: boolean

true as long as the timer is running and the touch events stay within the given tapAndHoldTolerance.

false
timerAutoScroll: boolean

Specifies if auto scrolling should be carried out via PanningHandler even if the container has scrollbars.

This disables scrollPointToVisible and uses PanningManager instead. If this is true then autoExtend is disabled.

It should only be used with a scroll buffer or when scrollbars are visible and scrollable in all directions.

false
toggleCells: ((show: boolean, cells: Cell[], includeEdges: boolean) => Cell[])

Sets the visible state of the specified cells and all connected edges if includeEdges is true. The change is carried out using cellsToggled. This method fires InternalEvent.TOGGLE_CELLS while the transaction is in progress. Returns the cells whose visible state was changed.

Type declaration

    • (show, cells, includeEdges): Cell[]
    • Parameters

      • show: boolean

        Boolean that specifies the visible state to be assigned.

      • cells: Cell[]

        Array of Cell whose visible state should be changed. If null is specified then the selection cells are used.

      • includeEdges: boolean

        Optional boolean indicating if the visible state of all connected edges should be changed as well. Default is true.

      Returns Cell[]

toggleCellStyle: ((key: keyof CellStateStyle, defaultValue?: boolean, cell?: Cell) => null | boolean)

Toggles the boolean value for the given key in the style of the given cell and returns the new value as boolean.

If no cell is specified then the selection cell is used.

Type declaration

    • (key, defaultValue?, cell?): null | boolean
    • Parameters

      • key: keyof CellStateStyle

        String representing the key for the boolean value to be toggled.

      • OptionaldefaultValue: boolean

        Optional boolean default value if no value is defined. Default is false.

      • Optionalcell: Cell

        Optional Cell whose style should be modified. Default is the selection cell.

      Returns null | boolean

toggleCellStyleFlags: ((key: NumericCellStateStyleKeys, flag: number, cells?: null | Cell[]) => void)

Toggles the given bit for the given key in the styles of the specified cells.

Type declaration

    • (key, flag, cells?): void
    • Parameters

      • key: NumericCellStateStyleKeys

        String representing the key to toggle the flag in.

      • flag: number

        Integer that represents the bit to be toggled.

      • Optionalcells: null | Cell[]

        Optional array of Cell to change the style for. Default is the selection cells.

      Returns void

toggleCellStyles: ((key: keyof CellStateStyle, defaultValue?: boolean, cells?: Cell[]) => null | boolean)

Toggles the boolean value for the given key in the style of the given cells and returns the new value as boolean.

If no cells are specified, then the selection cells are used.

For example, this can be used to toggle CellStateStyle.rounded or any other style with a boolean value.

Type declaration

    • (key, defaultValue?, cells?): null | boolean
    • Parameters

      • key: keyof CellStateStyle

        String representing the key for the boolean value to be toggled.

      • OptionaldefaultValue: boolean

        Optional boolean default value if no value is defined. Default is false.

      • Optionalcells: Cell[]

        Optional array of Cell whose styles should be modified. Default is the selection cells.

      Returns null | boolean

tolerance: number

Tolerance in pixels for a move to be handled as a single click.

4
translateCell: ((cell: Cell, dx: number, dy: number) => void)

Translates the geometry of the given cell and stores the new, translated geometry in the model as an atomic change.

translateToScrollPosition: boolean = false

Specifies if the graph should automatically convert the current scroll position to a translate in the graph view when a mouseUp event is received. This can be used to avoid conflicts when using autoScroll and ignoreScrollbars with no scrollbars in the container.

ungroupCells: ((cells?: null | Cell[]) => Cell[])

Ungroups the given cells by moving the children to their parents parent and removing the empty groups.

Type declaration

    • (cells?): Cell[]
    • Parameters

      • Optionalcells: null | Cell[]

        Array of cells to be ungrouped. If null is specified then the selection cells are used.

      Returns Cell[]

      the children that have been removed from the groups.

updateAlternateBounds: ((cell: null | Cell, geo: null | Geometry, willCollapse: boolean) => void)

Updates or sets the alternate bounds in the given geometry for the given cell depending on whether the cell is going to be collapsed.

If no alternate bounds are defined in the geometry and collapseToPreferredSize is true, then the preferred size is used for the alternate bounds.

The top, left corner is always kept at the same location.

Type declaration

    • (cell, geo, willCollapse): void
    • Parameters

      • cell: null | Cell

        Cell for which the geometry is being updated. Default is null.

      • geo: null | Geometry

        Geometry for which the alternate bounds should be updated. Default is null.

      • willCollapse: boolean

        Boolean indicating if the cell is going to be collapsed. Default is false.

      Returns void

updateCellSize: ((cell: Cell, ignoreChildren?: boolean) => Cell)

Updates the size of the given cell in the model using cellSizeUpdated. This method fires InternalEvent.UPDATE_CELL_SIZE while the transaction is in progress. Returns the cell whose size was updated.

Type declaration

    • (cell, ignoreChildren?): Cell
    • Parameters

      • cell: Cell

        Cell whose size should be updated.

      • OptionalignoreChildren: boolean

        if true, ignore the children of the cell when computing the size of the cell. Default is false.

      Returns Cell

updateGroupBounds: ((cells: Cell[], border?: number, moveGroup?: boolean, topBorder?: number, rightBorder?: number, bottomBorder?: number, leftBorder?: number) => Cell[])

Updates the bounds of the given groups to include all children and returns the passed-in cells.

Call this with the groups in parent to child order, top-most group first, the cells are processed in reverse order and cells with no children are ignored.

Type declaration

    • (cells, border?, moveGroup?, topBorder?, rightBorder?, bottomBorder?, leftBorder?): Cell[]
    • Parameters

      • cells: Cell[]

        The groups whose bounds should be updated. If this is null, then the selection cells are used.

      • Optionalborder: number

        Optional border to be added in the group. Default is 0.

      • OptionalmoveGroup: boolean

        Optional boolean that allows the group to be moved. Default is false.

      • OptionaltopBorder: number

        Optional top border to be added in the group. Default is 0.

      • OptionalrightBorder: number

        Optional top border to be added in the group. Default is 0.

      • OptionalbottomBorder: number

        Optional top border to be added in the group. Default is 0.

      • OptionalleftBorder: number

        Optional top border to be added in the group. Default is 0.

      Returns Cell[]

updateMouseEvent: ((me: InternalMouseEvent, evtName: string) => InternalMouseEvent)

Sets the graphX and graphY properties if the given InternalMouseEvent if required and returned the event.

Type declaration

updatePageBreaks: ((visible: boolean, width: number, height: number) => void)

Invokes from sizeDidChange to redraw the page breaks.

Type declaration

    • (visible, width, height): void
    • Parameters

      • visible: boolean

        Boolean that specifies if page breaks should be shown.

      • width: number

        Specifies the width of the container in pixels.

      • height: number

        Specifies the height of the container in pixels.

      Returns void

updateSelection: (() => void)

Removes selection cells that are not in the model from the selection.

updatingSelectionResource: string
useScrollbarsForPanning: boolean

Specifies if scrollbars should be used for panning in panGraph if any scrollbars are available.

If scrollbars are enabled in CSS, but no scrollbars appear because the graph is smaller than the container size, then no panning occurs if this is true.

true
validateCell: ((cell: Cell, context: CellState) => null | string)

Hook method for subclasses to return an error message for the given cell and validation context.

Any HTML breaks will be converted to linefeed in the calling method.

This implementation returns null.

Type declaration

    • (cell, context): null | string
    • Parameters

      • cell: Cell

        Cell that represents the cell to validate.

      • context: CellState

        Object that represents the global validation state.

      Returns null | string

validateEdge: ((edge: Cell, source: Cell, target: Cell) => null | string)

Hook method for subclasses to return an error message for the given edge and terminals.

This implementation returns null.

Type declaration

    • (edge, source, target): null | string
    • Parameters

      • edge: Cell

        Cell that represents the edge to validate.

      • source: Cell

        Cell that represents the source terminal.

      • target: Cell

        Cell that represents the target terminal.

      Returns null | string

validateGraph: ((cell?: null | Cell, context?: any) => null | string)

Validates the graph by validating each descendant of the given cell or the root of the model. Context is an object that contains the validation state for the complete validation run. The validation errors are attached to their cells using setCellWarning. Returns null in the case of successful validation or an array of strings (warnings) in the case of failed validations.

Type declaration

    • (cell?, context?): null | string
    • Parameters

      • Optionalcell: null | Cell

        Optional Cell to start the validation recursion. Default is the graph root.

      • Optionalcontext: any

        Object that represents the global validation state.

      Returns null | string

validationAlert: ((message: string) => void)

Displays the given validation error in a dialog.

This implementation uses window.alert.

vertexLabelsMovable: boolean

Specifies the return value for vertices in isLabelMovable.

false
verticalPageBreaks: null | any[]
null
view: GraphView

Holds the GraphView that caches the CellStates for the cells.

warningImage: ImageBox = ...

Specifies the Image for the image to be used to display a warning overlay. See setCellWarning. Default value is Client.imageBasePath + '/warning'. The extension for the image depends on the platform. It is '.png' on the Mac and '.gif' on all other platforms.

zoom: ((factor: number, center?: boolean) => void)

Zooms the graph using the given factor. Center is an optional boolean argument that keeps the graph scrolled to the center. If the center argument is omitted, then centerZoom will be used as its value.

zoomActual: (() => void)

Resets the zoom in the view to the original scale.

zoomFactor: number

Specifies the factor used for zoomIn and zoomOut.

1.2 (120%)
zoomIn: (() => void)

Zooms into the graph by zoomFactor.

zoomOut: (() => void)

Zooms out of the graph by zoomFactor.

zoomTo: ((scale: number, center?: boolean) => void)

Zooms the graph to the given scale with an optional boolean center argument, which is passed to zoom.

zoomToRect: ((rect: Rectangle) => void)

Zooms the graph to the specified rectangle. If the rectangle does not have same aspect ratio as the display container, it is increased in the smaller relative dimension only until the aspect match. The original rectangle is centralised within this expanded one.

Note that the input rectangular must be un-scaled and un-translated.

Type declaration

    • (rect): void
    • Parameters

      • rect: Rectangle

        The un-scaled and un-translated rectangluar region that should be just visible after the operation

      Returns void

Methods

  • Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.

    The parameters of the listener are the sender and an EventObject.

    Parameters

    • name: string
    • funct: Function

    Returns void

  • Updates the model in a transaction.

    Parameters

    • fn: (() => void)

      the update to be performed in the transaction.

        • (): void
        • Returns void

    Returns void

  • Centers the graph in the container.

    Parameters

    • horizontal: boolean = true

      Optional boolean that specifies if the graph should be centered horizontally. Default is true.

    • vertical: boolean = true

      Optional boolean that specifies if the graph should be centered vertically. Default is true.

    • cx: number = 0.5

      Optional float that specifies the horizontal center. Default is 0.5.

    • cy: number = 0.5

      Optional float that specifies the vertical center. Default is 0.5.

    Returns void

  • Returns the textual representation for the given cell.

    This implementation returns the node name or string-representation of the user object.

    The following returns the label attribute from the cells user object if it is an XML node.

    Parameters

    • cell: Cell

      Cell whose textual representation should be returned.

    Returns string

    graph.convertValueToString = function(cell)
    {
    return cell.getAttribute('label');
    }

    See also: cellLabelChanged.

  • Creates a new GraphSelectionModel to be used in this graph.

    Returns GraphSelectionModel

  • Hook method that creates the new vertex for insertVertex.

    Parameters

    • parent: null | Cell

      the parent of the new vertex. If not set, use the default parent.

    • id: undefined | null | string

      Optional string that defines the id of the new vertex. If not set, the id is auto-generated when creating the vertex.

    • value: any

      Object to be used as the user object.

    • x: number

      the x coordinate of the vertex.

    • y: number

      the y coordinate of the vertex.

    • width: number

      the width of the vertex.

    • height: number

      the height of the vertex.

    • Optionalstyle: CellStyle

      the cell style.

    • Optionalrelative: boolean

      specifies if the geometry is relative. Default is false.

    • OptionalgeometryClass: typeof Geometry

      class reference to a class derived from Geometry. This can be useful for defining custom constraints. Default is Geometry.

    Returns Cell

  • Destroys the graph and all its resources.

    Returns void

  • Resizes the container for the given graph width and height.

    Parameters

    • width: number
    • height: number

    Returns void

  • Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation (see Utils#bind).

    Example:

    fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN))
    

    Parameters

    • evt: EventObject

      EventObject that represents the event.

    • sender: null | EventTarget = null

      Optional sender to be passed to the listener. Default value is the return value of .

    Returns void

  • Scales the graph such that the complete diagram fits into and returns the current scale in the view. To fit an initial graph prior to rendering, set GraphView#rendering to false prior to changing the model and execute the following after changing the model.

    graph.fit();
    graph.view.rendering = true;
    graph.refresh();

    To fit and center the graph, the following code can be used.

    let margin = 2;
    let max = 3;

    let bounds = graph.getGraphBounds();
    let cw = graph.container.clientWidth - margin;
    let ch = graph.container.clientHeight - margin;
    let w = bounds.width / graph.view.scale;
    let h = bounds.height / graph.view.scale;
    let s = Math.min(max, Math.min(cw / w, ch / h));

    graph.view.scaleAndTranslate(s,
    (margin + cw - w * s) / (2 * s) - bounds.x / graph.view.scale,
    (margin + ch - h * s) / (2 * s) - bounds.y / graph.view.scale);

    Parameters

    • border: number = ...

      Optional number that specifies the border. Default is .

    • keepOrigin: boolean = false

      Optional boolean that specifies if the translate should be changed. Default is false.

    • margin: number = 0

      Optional margin in pixels. Default is 0.

    • enabled: boolean = true

      Optional boolean that specifies if the scale should be set or just returned. Default is true.

    • ignoreWidth: boolean = false

      Optional boolean that specifies if the width should be ignored. Default is false.

    • ignoreHeight: boolean = false

      Optional boolean that specifies if the height should be ignored. Default is false.

    • maxHeight: null | number = null

      Optional maximum height.

    Returns number

  • Returns the size of the border and padding on all four sides of the container. The left, top, right and bottom borders are stored in the x, y, width and height of the returned Rectangle, respectively.

    Returns Rectangle

  • Returns the offset to be used for the cells inside the given cell. The root and layer cells may be identified using GraphDataModel.isRoot and GraphDataModel.isLayer. For all other current roots, the GraphView.currentRoot field points to the respective cell, so that the following holds: cell == this.view.currentRoot. This implementation returns null.

    Parameters

    • cell: Cell

      mxCell whose offset should be returned.

    Returns null | Point

  • Returns string

  • Returns
        | "svg"
        | "mixedHtml"
        | "preferHtml"
        | "strictHtml"

  • Returns the string to be used as the link for the given cell.

    This implementation returns null.

    Parameters

    • cell: Cell

      Cell whose link should be returned.

    Returns null | string

  • Returns a decimal number representing the amount of the width and height of the given cell that is allowed to overlap its parent. A value of 0 means all children must stay inside the parent, 1 means the child is allowed to be placed outside of the parent such that it touches one of the parents sides. If isAllowOverlapParent returns false for the given cell, then this method returns 0.

    Parameters

    • cell: Cell

      mxCell for which the overlap ratio should be returned.

    Returns number

  • Returns the translation to be used if the given cell is the root cell as an Point. This implementation returns null.

    To keep the children at their absolute position while stepping into groups, this function can be overridden as follows.

    Parameters

    • cell: null | Cell

      mxCell that represents the root.

    Returns null | Point

    var offset = new mxPoint(0, 0);

    while (cell != null)
    {
    var geo = this.model.getGeometry(cell);

    if (geo != null)
    {
    offset.x -= geo.x;
    offset.y -= geo.y;
    }

    cell = this.model.getParent(cell);
    }

    return offset;
  • Called when the graph model changes. Invokes processChange on each item of the given array to update the view accordingly.

    Parameters

    • changes: any[]

      Array that contains the individual changes.

    Returns void

  • Uses the root of the model as the root of the displayed cell hierarchy and selects the previous root.

    Returns void

  • Adds a new edge into the given parent Cell using value as the user object and the given source and target as the terminals of the new edge. The id and style are used for the respective properties of the new Cell, which is returned.

    Parameters

    • parent: null | Cell

      Cell that specifies the parent of the new edge. If not set, use the default parent.

    • id: undefined | null | string

      Optional string that defines the Id of the new edge. If not set, the id is auto-generated when creating the vertex.

    • value: EdgeParametersValue

      Object to be used as the user object which is generally used to display the label of the edge. The default implementation handles string object.

    • Optionalsource: null | Cell

      Cell that defines the source of the edge.

    • Optionaltarget: null | Cell

      Cell that defines the target of the edge.

    • Optionalstyle: CellStyle

      Optional object that defines the cell style.

    Returns Cell

  • Adds a new edge into the given parent Cell using value as the user object and the given source and target as the terminals of the new edge. The id and style are used for the respective properties of the new Cell, which is returned.

    Parameters

    Returns Cell

  • Adds a new vertex into the given parent Cell using value as the user object and the given coordinates as the Geometry of the new vertex. The id and style are used for the respective properties of the new Cell, which is returned.

    IMPORTANT: this is a legacy method to ease the migration from mxGraph. Use the insertVertex method with a single object parameter instead.

    When adding new vertices from a mouse event, one should take into account the offset of the graph container and the scale and translation of the view in order to find the correct unscaled, untranslated coordinates using Graph#getPointForEvent as follows:

    const pt = graph.getPointForEvent(evt);
    const parent = graph.getDefaultParent();
    graph.insertVertex(parent, null, 'Hello, World!', pt.x, pt.y, 220, 30);

    For adding image cells, the style parameter can be assigned as

    style: {
    image: imageUrl,
    }

    See Graph for more information on using images.

    Parameters

    • parent: null | Cell

      the parent of the new vertex. If not set, use the default parent.

    • id: undefined | null | string

      Optional string that defines the id of the new vertex. If not set, the id is auto-generated when creating the vertex.

    • value: any

      Object to be used as the user object.

    • x: number

      the x coordinate of the vertex.

    • y: number

      the y coordinate of the vertex.

    • width: number

      the width of the vertex.

    • height: number

      the height of the vertex.

    • Optionalstyle: CellStyle

      the cell style.

    • Optionalrelative: boolean

      specifies if the geometry is relative. Default is false.

    • OptionalgeometryClass: typeof Geometry

      class reference to a class derived from Geometry. This can be useful for defining custom constraints. Default is Geometry.

    Returns Cell

  • Adds a new vertex into the given parent Cell using value as the user object and the given coordinates as the Geometry of the new vertex. The id and style are used for the respective properties of the new Cell, which is returned.

    When adding new vertices from a mouse event, one should take into account the offset of the graph container and the scale and translation of the view in order to find the correct unscaled, untranslated coordinates using Graph#getPointForEvent as follows:

    const pt = graph.getPointForEvent(evt);
    const parent = graph.getDefaultParent();
    graph.insertVertex({
    parent,
    position: [pt.x, pt.y],
    size: [220, 30],
    value: 'Hello, World!',
    });

    For adding image cells, the style parameter can be assigned as

    style: {
    image: imageUrl,
    }

    See Graph for more information on using images.

    Parameters

    Returns Cell

  • Returns true if the given cell is allowed to be placed outside of the parents area.

    Parameters

    • cell: Cell

      mxCell that represents the child to be checked.

    Returns boolean

  • Returns true if perimeter points should be computed such that the resulting edge has only horizontal or vertical segments.

    Parameters

    Returns boolean

  • Returns true if the given cell is a valid root for the cell display hierarchy. This implementation returns true for all non-null values.

    Parameters

    • cell: Cell

      mxCell which should be checked as a possible root.

    Returns boolean

  • Processes the given change and invalidates the respective cached data in GraphView. This fires a root event if the root has changed in the model.

    Parameters

    • change: any

      Object that represents the change on the model.

    Returns void

  • Clears all cell states or the states for the hierarchy starting at the given cell and validates the graph. This fires a refresh event as the last step.

    Parameters

    • cell: null | Cell = null

      Optional Cell for which the cell states should be cleared.

    Returns void

  • Scrolls the graph to the given point, extending the graph container if specified.

    Parameters

    • x: number
    • y: number
    • extend: boolean = false
    • border: number = 20

    Returns void

  • Specifies if loops are allowed.

    Parameters

    • value: boolean

      Boolean indicating if loops are allowed.

    Returns void

  • Sets the value of border.

    Parameters

    • value: number

      Positive integer that represents the border to be used.

    Returns void

  • Sets the defaultParent to the given cell. Set this to null to return the first child of the root in getDefaultParent.

    Parameters

    Returns void

  • Specifies if the graph should allow any interactions. This implementation updates enabled.

    Parameters

    • value: boolean

      Boolean indicating if the graph should be enabled.

    Returns void

  • Specifies if the graph should allow multiple connections between the same pair of vertices.

    Parameters

    • value: boolean

      Boolean indicating if the graph allows multiple connections between the same pair of vertices.

    Returns void

  • Parameters

    • value: boolean

      Boolean indicating if the container should be resized.

    Returns void