【无标题】

Model
阅读时间约 12 分钟
配置
model
画布对应的模型,默认创建一个新模型。

方法
isNode(…)
isNode(cell: Cell): cell is Node
返回指定的 Cell 是否是节点。

参数

名称 类型 必选 默认值 描述
cell Cell ✓ 指定的 Cell。
isEdge(…)
isEdge(cell: Cell): cell is Edge
返回指定的 Cell 是否是边。

参数

名称 类型 必选 默认值 描述
cell Cell ✓ 指定的 Cell。
createNode(…)
createNode(metadata: Node.Metadata): Node
创建节点。

参数

名称 类型 必选 默认值 描述
metadata Node.Metadata ✓ 节点元数据。
addNode(…)
addNode(metadata: Node.Metadata, options?: AddOptions): Node
addNode(node: Node, options?: AddOptions): Node
添加节点到画布,返回添加的节点。

参数

名称 类型 必选 默认值 描述
node Node.Metadata | Node ✓ 节点元数据或节点实例。
options.silent boolean false 为 true 时不触发 ‘node:added’ 和 ‘cell:added’ 事件和画布重绘。
options.sort boolean true 是否按照 zIndex 排序。
options…others object 其他自定义键值对,可以在事件回调中使用。
removeNode(…)
removeNode(nodeId: string, options?: RemoveOptions): Node | null
removeNode(node: Node, options?: RemoveOptions): Node | null
删除节点,返回删除的节点。

参数

名称 类型 必选 默认值 描述
node string | Node ✓ 节点 ID 或节点实例。
options.silent boolean false 为 true 时不触发 ‘node:removed’ 和 ‘cell:removed’ 事件和画布重绘。
options…others object 其他自定义键值对,可以在事件回调中使用。
createEdge(…)
createEdge(metadata: Edge.Metadata): Edge
创建边。

参数

名称 类型 必选 默认值 描述
metadata Edge.Metadata ✓ 节点元数据。
addEdge(…)
addEdge(metadata: Edge.Metadata, options?: AddOptions): Edge
addEdge(edge:Edge, options?: AddOptions): Edge
添加边到画布,返回添加的边。

参数

名称 类型 必选 默认值 描述
edge Edge.Metadata | Edge ✓ 边元数据或边实例。
options.silent boolean false 为 true 时不触发 ‘edge:added’ 和 ‘cell:added’ 事件和画布重绘。
options.sort boolean true 是否按照 zIndex 排序。
options…others object 其他自定义键值对,可以在事件回调中使用。
removeEdge(…)
removeEdge(edgeId: string, options?: RemoveOptions): Edge | null
removeEdge(edge: Edge, options?: RemoveOptions): Edge | null
删除边,返回删除的边。

参数

名称 类型 必选 默认值 描述
edge string | Edge ✓ 边 ID 或边实例。
options.silent boolean false 为 true 时不触发 ‘edge:removed’ 和 ‘cell:removed’ 事件和画布重绘。
options…others object 其他自定义键值对,可以在事件回调中使用。
addCell(…)
addCell(cell: Cell | Cell[], options?: AddOptions): this
添加节点或边到画布。

参数

名称 类型 必选 默认值 描述
cell Cell | Cell[] ✓ 节点实例或边实例,支持传入数组同时添加多个节点或边。
options.silent boolean false 为 true 时不触发 ‘cell:added’、‘node:added’ 和 ‘edge:added’ 事件和画布重绘。
options.sort boolean true 是否按照 zIndex 排序。
options…others object 其他自定义键值对,可以在事件回调中使用。
removeCell(…)
removeCell(cellId: string, options?: RemoveOptions): Cell | null
removeCell(cell: Cell, options?: RemoveOptions): Cell | null
删除节点或边,返回删除的节点或边。

参数

名称 类型 必选 默认值 描述
cell

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值