Options
All
  • Public
  • Public/Protected
  • All
Menu

Cells are the elements of the graph model. They represent the state of the groups, vertices and edges in a graph.

Custom attributes

For custom attributes we recommend using an XML node as the value of a cell. The following code can be used to create a cell with an XML node as the value:

example
var doc = mxUtils.createXmlDocument();
var node = doc.createElement('MyNode')
node.setAttribute('label', 'MyLabel');
node.setAttribute('attribute1', 'value1');
graph.insertVertex(graph.getDefaultParent(), null, node, 40, 40, 80, 30);

For the label to work, mxGraph.convertValueToString and mxGraph.cellLabelChanged should be overridden as follows:

example
graph.convertValueToString(cell)
{
  if (mxUtils.isNode(cell.value))
  {
    return cell.getAttribute('label', '')
  }
};

var cellLabelChanged = graph.cellLabelChanged;
graph.cellLabelChanged(cell, newValue, autoSize)
{
  if (mxUtils.isNode(cell.value))
  {
    // Clones the value for correct undo/redo
    var elt = cell.value.cloneNode(true);
    elt.setAttribute('label', newValue);
    newValue = elt;
  }

  cellLabelChanged.apply(this, arguments);
};

Hierarchy

  • mxCell

Indexable

[key: string]: any

Cells are the elements of the graph model. They represent the state of the groups, vertices and edges in a graph.

Custom attributes

For custom attributes we recommend using an XML node as the value of a cell. The following code can be used to create a cell with an XML node as the value:

Index

Constructors

constructor

  • Parameters

    • Optional value: any

      Optional object that represents the cell value.

    • Optional geometry: mxGeometry

      Optional that specifies the geometry.

    • Optional style: string

      Optional formatted string that defines the style.

    Returns mxCell

Properties

children

children: mxCell[]

Holds the child cells.

collapsed

collapsed: boolean

Specifies whether the cell is collapsed. Default is false.

connectable

connectable: boolean

Specifies whether the cell is connectable. Default is true.

edge

edge: boolean

Specifies whether the cell is an edge. Default is false.

edges

edges: mxCell[]

Holds the edges.

geometry

geometry: mxGeometry

Holds the . Default is null.

id

id: string

Holds the Id. Default is null.

mxTransient

mxTransient: string[]

List of members that should not be cloned inside . This field is passed to <mxUtils.clone> and is not made persistent in . This is not a convention for all classes, it is only used in this class to mark transient fields since transient modifiers are not supported by the language.

overlays

overlays: mxCellOverlay[]
see

{mxGraph.getCellOverlays}

parent

parent: mxCell

Reference to the parent cell.

source

source: mxCell

Reference to the source terminal.

style

style: string

Holds the style as a string of the form [(stylename|key=value);]. Default is null.

target

target: mxCell

Reference to the target terminal.

value

value: any

Holds the user object. Default is null.

vertex

vertex: boolean

Specifies whether the cell is a vertex. Default is false.

visible

visible: boolean

Specifies whether the cell is visible. Default is true.

Methods

clone

  • Returns a clone of the cell. Uses to clone the user object. All fields in are ignored during the cloning.

    Returns mxCell

cloneValue

  • cloneValue(): any

getAttribute

  • getAttribute(name: string, defaultValue: any): any
  • Returns the specified attribute from the user object if it is an XML node.

    Parameters:

    Parameters

    • name: string
    • defaultValue: any

    Returns any

getChildAt

  • getChildAt(index: number): mxCell

getChildCount

  • getChildCount(): number

getEdgeAt

  • getEdgeAt(index: number): mxCell

getEdgeCount

  • getEdgeCount(): number

getEdgeIndex

  • getEdgeIndex(edge: mxCell): number

getGeometry

getId

  • getId(): string

getIndex

  • getIndex(child: mxCell): number
  • Returns the index of the specified child in the child array.

    Parameters:

    Parameters

    Returns number

getParent

getStyle

  • getStyle(): string
  • Returns a string that describes the