- Represent any directed graph
- Multiple root nodes possible
- Nodes can have multiple parents
- Drag and drop node movement
- Edges between nodes can be drawn intuitively
- Edges can be deleted by selecting them and clicking the Delete key
- Graph can be panned and zoomed
npm i --save react-dnd-tree
import DnDTree from 'react-dnd-tree'
function Component(props) {
const DnDTree = require('react-dnd-tree').default
return (
<DnDTree
nodes={model.nodes}
edges={model.edges}
height={400}
edgeDraw
errorHandler={errorHandler}
updateHandler={updateHandler}
edgeType='curve'
onNodeSelected={nodeSelected}
/>
)
}
nodes
: list of node objects of format { label }edges
: list of edge objects of format { from: int, to: int } where from, to are indices into the nodes listedgeDraw
: default=True, whether you can draw edges between nodeserrorHandler
: callback function taking an error messageonNodeSelected
: callback function taking the selected node objectupdateHandler
: callback taking (nodes, edges) every time the user updates the graphedgeType
: (curve | line) the line interpolation style between nodes