Get/Set

2 min read

graph.get(key)

Get an property of graph by key.

Parameters

NameTypeRequiredDescription
keystringtrueKey of the property.

Usage

// get the group
const group = graph.get('group');

// get the canvas instance
const canvas = graph.get('canvas');

// get the value of autoPaint
const autoPaint = graph.get('autoPaint');

graph.set(key, val)

Set the value to an property.

Parameters

NameTypeRequiredDescription
keystringtrueThe key of the property.
valstring / Object / ArraytrueThe value of the property.

Usage

// Set capture to false
graph.set('capture', false);

// Set customGroup to group
graph.set('customGroup', group);

// Set nodeIdList to [1, 3, 5]
graph.set('nodeIdList', [1, 3, 5]);

graph.getContainer()

Get the DOM container of the graph.

Parameter

No parameter.

Usage

graph.getContainer();

graph.getGroup()

Get the root graphics group of the graph.

Parameter

No parameter.

Usage

graph.getGroup();

graph.getMinZoom()

Get the minZoom for the graph, which is the lower limit of the zoom ratio.

Parameter

No parameter

Usage

graph.getMinZoom();

graph.setMinZoom(ratio)

Set the minZoom for the graph, which is the lower limit of the zoom ratio.

Parameter

NameTypeRequiredDescription
rationumbertrueThe minimum zoom ratio value

Usage

graph.setMinZoom(0.001);

graph.getMaxZoom()

Get the maxZoom for the graph, which is the upper limit of the zoom ratio.

Parameter

No parameter.

Usage

graph.getMaxZoom();

graph.setMaxZoom(ratio)

Set the maxZoom for the graph, which is the upper limit of the zoom ratio.

Parameter

NameTypeRequiredDescription
rationumbertrueThe maximum zoom ratio value

Usage

graph.setMaxZoom(1000);

graph.getWidth()

Get the current width of the graph.

Parameter

No parameter.

Usage

graph.getWidth();

graph.getHeight()

Get the current height of the graph.

Parameter

No parameter.

Usage

graph.getHeight();