Graph
Configuration
new Graph(options: Options)
| Option | Type | Required | Description | Default Value |
|---|---|---|---|---|
| container | HTMLElement | string |
✓ | The container of the canvas. A string is resolved only as an element ID, without a leading #. |
|
| width | number |
The width of the canvas, defaults to the container width. | - | |
| height | number |
The height of the canvas, defaults to the container height. | - | |
| scaling | { min?: number, max?: number } |
The minimum and maximum zoom levels of the canvas. | { min: 0.01, max: 16 } |
|
| autoResize | boolean | Element | Document |
Whether to listen to container size changes and automatically update the canvas size. | false |
|
| panning | boolean | PanningManager.Options |
Whether the canvas can be panned, defaults to disabled. | false |
|
| mousewheel | boolean | MouseWheel.Options |
Whether the mouse wheel can zoom, defaults to disabled. | false |
|
| grid | boolean | number | GridManager.Options |
The grid, defaults to a 10px grid but does not draw the grid background. | false |
|
| background | false | BackgroundManager.Options |
The background, defaults to not drawing the background. | false |
|
| translating | Translating.Options |
Restricts node movement. After a node is moved, automatically offset when it overlaps with other nodes. | { restrict: false, autoOffset: true } |
|
| embedding | boolean | Embedding.Options |
Whether to enable nested nodes, defaults to disabled. | false |
|
| connecting | Connecting.Options |
The connection options. | { snap: false, ... } |
|
| highlighting | Highlighting.Options |
The highlighting options. | {...} |
|
| interacting | Interacting.Options |
Customizes the interaction behavior of nodes and edges. | { edgeLabelMovable: false } |
|
| magnetThreshold | number | onleave |
The number of times the mouse can move before triggering a connection, or set to onleave to trigger a connection when the mouse leaves an element. |
0 |
|
| moveThreshold | number |
The number of times the mouse can move before triggering a mousemove event. |
0 |
|
| clickThreshold | number |
When the mouse moves more than the specified number of times, the mouse click event will not be triggered. | 0 |
|
| preventDefaultContextMenu | boolean |
Whether to disable the browser’s default right-click menu. | true |
|
| preventDefaultBlankAction | boolean |
Whether to disable the default mouse behavior when clicking on a blank area of the canvas. | true |
|
| async | boolean |
Whether to render asynchronously. | true |
|
| virtual | boolean | VirtualOptions |
Whether to only render the visible area of the canvas; when an object is provided, you can configure the buffer margin margin and the switch enabled. |
false |
|
| onPortRendered | (args: OnPortRenderedArgs) => void |
The callback triggered when a port is rendered. | - | |
| onEdgeLabelRendered | (args: OnEdgeLabelRenderedArgs) => void | ((args: OnEdgeLabelRenderedArgs) => void) |
The callback triggered when an edge label is rendered, And it can return a cleanup function, which will be executed when the label is destroyed. | - | |
| createCellView | (cell: Cell) => CellView | null | undefined |
Customizes the view of a cell. | - |