创建边缘(拖动并单击)
内置边缘创建,具有由实时“阴影边缘”预览支持的两种交互样式:单击-单击(单击源节点,然后单击目标)和拖放(从一个节点拖到另一个节点)。
单击 编辑图形(右上角),然后单击 添加边,然后连接两个节点 - 或者只是从一个节点拖动到另一个节点。每个新边都会触发 edgeAdd 数据事件,这里会弹出一个 toast。
js
// Edge creation lives in the full UI mode. Turn it on and the toolbar's
// Edit Graph → Add Edge starts a click-click (or drag) connect session — the
// shadow-edge preview and both interaction styles come for free.
const options = {
// Off: `full` mode brings a minimap and the data dock, and this card is about
// neither (see the Minimap and Data table cards for those).
UI: { mode: 'full', minimap: false, table: false }
}js
const data = {
nodes: [
{ id: 'alice', data: { label: 'Alice' } },
{ id: 'bob', data: { label: 'Bob' } },
{ id: 'carol', data: { label: 'Carol' } },
{ id: 'dave', data: { label: 'Dave' } },
{ id: 'erin', data: { label: 'Erin' } }
],
edges: [
{ from: 'alice', to: 'bob' },
{ from: 'alice', to: 'carol' }
]
}