It is not only a fully functional graph visualization library, but also an explorer of data relationships.
!!!###!!!title=DAG Flow Editor——VisActor/VGraph tutorial documents!!!###!!!!!!###!!!description=Users can easily build a directed graph with simple icon clicks. Although not as flexible as dragging nodes and connecting lines to edit a directed graph, it is more efficient and produces a higher quality directed graph, with less need for post-data verification. It can also be used with the Viewer component, and react nodes can provide more possibilities for display and interaction. vGraph encapsulates the basic functions into a component, which can be referenced as follows:```javascriptimport { DAGFlowEditor } from '@visactor/vgraph';const editor = new DAGFlowEditor(options);```**Note:** In order to ensure the data order of the first layer of nodes, this component will generate a virtual root node with an id of `vgraphDagFlowRoot`. It is recommended to save this data to ensure the order of the nodes when it is opened again after saving.!!!###!!!
Directed Graph Restricted Editing
Users can easily build a directed graph with simple icon clicks. Although not as flexible as dragging nodes and connecting lines to edit a directed graph, it is more efficient and produces a higher quality directed graph, with less need for post-data verification. It can also be used with the Viewer component, and react nodes can provide more possibilities for display and interaction. vGraph encapsulates the basic functions into a component, which can be referenced as follows:
import { DAGFlowEditor } from'@visactor/vgraph';
const editor = new DAGFlowEditor(options);
Note: In order to ensure the data order of the first layer of nodes, this component will generate a virtual root node with an id of vgraphDagFlowRoot. It is recommended to save this data to ensure the order of the nodes when it is opened again after saving.
Data in the graph. If empty, you can directly call pipelineEditor.initEmptyEditor().
container
string | HTMLDivElement
[Required] Pipeline container
graphSize
number[]
[Required] Container size, in the format [width, height]
padding
number[] | number
Padding on all four sides of the canvas
layout
object
Layout settings
layout.rankDir
'LR' | 'TB'
Layout direction, LR is from left to right, TB is from top to bottom
layout.rankSep
number
Spacing between nodes in different columns
layout.nodeSep
number
Spacing between nodes in the same column
layout.edgeSep
number
Distance between nodes and connection lines
layout.ignoreControlPoints
boolean
Whether to ignore the control points calculated by the layout, default is false
layout.coordAssignment
'compact' | 'treeLike'
Node layout method, default is compact. In treeLike layout, the positions of child nodes under different parent nodes will not overlap. Refer to Tree Editing - React Node
Add a child node to the specified node. By default, the new node will be directly associated with the existing child nodes. You can set linkChildren to false to cancel this behavior. The new node will be selected directly.
Add a preceding sibling node to the specified node. By default, the new node will inherit the child nodes of the original node. You can set linkChildren to false to cancel this behavior. The new node will be selected directly.
Add a subsequent sibling node to the specified node. By default, the new node will inherit the child nodes of the original node. You can set linkChildren to false to cancel this behavior. The new node will be selected directly.
If you have custom operations, you can save the data before and after performing the operation, and use this method to store it in the operation stack to support undo and redo operations.
getSnapshot
() => SnapshotData;
Generate a snapshot of the current state of the editor, which is used to implement undo and redo for custom operations in conjunction with batch operations batchChange.
If you have custom operations, you can call the instance method getSnapshot() before and after performing the operation to save the data, and then use this method to store it in the operation stack to support undo and redo operations. For a usage case, please see Batch Add Nodes.
Get the Graph instance corresponding to the solution.
getSelectedNode
() => Node | null
Get the currently selected node. Since operations such as undo and redo may cause frequent addition and deletion of nodes, it is recommended to use this interface every time to get the currently operated node.
selectionIntoView
() => void
Pan the canvas to ensure that the currently selected node is in the viewport.
Insert a node between the two nodes of the specified connection line.
copy
async (node: Node, children = false)=>boolean
Asynchronous function. Copy the specified node. If children is true, the entire subtree with this node as the root will be copied. Returns whether the copy was successful.
Asynchronous function. Paste the copied node or subtree as a child of the specified node. edgeConfigs is the custom connection line attribute configuration for connecting the specified node and the root node in the pasted node.