// Convert element definitions to a compact columnar payload for bulk loading or binary serialization
cytoscape.toColumnarElements(defs: ElementsDefinition | ElementDefinition, options?: ToColumnarOptions): ColumnarElementsConvert element definitions to a compact columnar payload for bulk loading or binary serialization. Node fields use typed arrays, and edge endpoints refer to indices in the payload's node list.
This form does not preserve locked, grabbable or pannable overrides. Pass definitions directly to the constructor when those flags must survive. Use the refs option to include references to nodes already in the graph.
| Name | Description |
|---|---|
defs: ElementsDefinition | ElementDefinition | one element, an array, or |
options: ToColumnarOptions?Default: {} |
|
Fields of defs
| Name | Description |
|---|---|
group: GroupName? | inferred from |
data: DefinitionData<Data>? | |
position: Position? | nodes only |
collapsed: boolean? | nodes only: persisted miniature-compound state |
appliedCollapseScale: number? | nodes only: current applied factor when collapsed; omitted uses the configured collapse-scale |
selected: boolean? | |
selectable: boolean? | |
grabbable: boolean? | |
locked: boolean? | |
pannable: boolean? | dragging this element pans the graph instead (default: true for edges, false for nodes) |
nodes: ElementDefinition<NodeData>[]? | |
edges: ElementDefinition<EdgeData>[]? |
Fields of options
| Name | Description |
|---|---|
refs: boolean? | Carry what the payload names but does not hold as node references
instead of throwing: an edge endpoint or a node parent that is not a node
in the payload goes into the result's |
ColumnarElementsthe equivalent columnar payload — self-contained, or with refs when that option is on and something was referenced
Example
const columns = cytoscape.toColumnarElements([{ data: { id: 'new' } }]);console.log(cy.add(columns).length); // 1if an edge lacks a source or target; without refs, also if an edge names a source or target that is not a node in the same payload — columnar payloads are self-contained unless they carry references; and on an unknown option