eo-draw-canvas
<eo-draw-canvas>
用于手工绘图的画布。
注意:将配套另外一个用于展示的画布构件。
Examples
Basic
Line settings
设置属性 lineSettings
来调整新的连线的样式,例如使用折线或直线。注意,该设置不影响已有的 edge 的连线样式。
Force layout
Dagre layout
Properties
Name | Description | Type | Default | Required |
---|---|---|---|---|
cells | 仅当初始化时使用,渲染后重新设置 | InitialCell[] | ||
layout | LayoutType | |||
layoutOptions | LayoutOptions | |||
defaultNodeSize | SizeTuple | [100,20] | ||
defaultNodeBricks | NodeBrickConf[] | |||
degradedThreshold | 当节点数量达到或超过 | number | 500 | |
degradedNodeLabel | 设置节点将降级展示时显示的名称。 | string | "<% DATA.node.id %>" | |
defaultEdgeLines | 使用条件判断设置默认的边对应的连线。在
| EdgeLineConf[] | ||
activeTarget | ActiveTarget | null | |||
fadeUnrelatedCells | 当 | boolean | ||
zoomable | boolean | true | ||
scrollable | boolean | true | ||
pannable | boolean | true | ||
allowEdgeToArea | boolean | false | ||
dragBehavior | 按住鼠标拖动时的行为:
| DragBehavior | "none" | |
ctrlDragBehavior | 按住 ctrl 键并按住鼠标拖动时的行为:
| CtrlDragBehavior | "none" | |
scaleRange | RangeTuple | |||
lineSettings | LineSettings | |||
lineConnector | LineConnecterConf | boolean | |||
doNotResetActiveTargetForSelector | 选择器,点击该选择器对应的元素时不重置 | string | ||
doNotResetActiveTargetOutsideCanvas | 在画布外点击时不重置 | boolean |
Events
Name | Description | Event Detail |
---|---|---|
activeTarget.change | ActiveTarget | null | |
| MoveCellPayload | |
cell.move | MoveCellPayload | |
cells.move | MoveCellPayload[] | |
cell.resize | ResizeCellPayload | |
| Cell | |
cell.delete | Cell | |
cells.delete | Cell[] | |
cell.contextmenu | CellContextMenuDetail | |
edge.add | 通过画布绘图的方式添加边(手动调用 | ConnectNodesDetail |
edge.view.change | EdgeViewChangePayload | |
decorator.text.change | DecoratorTextChangeDetail | |
node.container.change | node节点跟容器组关系改变事件,有containerCell是新增关系,否则删除关系 | MoveCellPayload[] |
scale.change | 缩放变化后,从素材库拖拽元素进画布时,拖拽图像应设置对应的缩放比例。 | number |
Methods
Name | Description | Params | Returns |
---|---|---|---|
dropNode | param_1: DropNodeInfo | Promise<NodeCell | null> | |
dropDecorator | param_1: DropDecoratorInfo | Promise<DecoratorCell | null> | |
addNodes | nodes: AddNodeInfo[] | Promise<NodeCell[]> | |
addEdge | param_1: AddEdgeInfo | Promise<EdgeCell> | |
manuallyConnectNodes | source: NodeId | Promise<ConnectNodesDetail> | |
updateCells | cells: InitialCell[] , ctx: UpdateCellsContext | Promise<{ updated: Cell[] }> |
Type references
BaseBrickCell
extends BaseCell
Name | Type | Required | Description |
---|---|---|---|
tag | "brick" | ||
useBrick | UseSingleBrickConf |
BaseCell
Name | Type | Required | Description |
---|---|---|---|
type | "node" | "edge" | "decorator" | ✅ | |
data | unknown |
BaseNodeCell
extends BaseCell
Name | Type | Required | Description |
---|---|---|---|
type | "node" | ✅ | |
id | NodeId | ✅ | |
containerId | NodeId | ||
view | NodeView | ✅ |
NodeView
extends InitialNodeView
Name | Type | Required | Description |
---|---|---|---|
width | number | ✅ | |
height | number | ✅ |
InitialNodeView
Name | Type | Required | Description |
---|---|---|---|
x | number | ✅ | |
y | number | ✅ | |
width | number | ||
height | number |
BaseEdgeCell
extends BaseCell
Name | Type | Required | Description |
---|---|---|---|
type | "edge" | ✅ | |
source | NodeId | ✅ | |
target | NodeId | ✅ | |
view | EdgeView |
EdgeView
extends LineSettings
Name | Type | Required | Description |
---|---|---|---|
exitPosition | NodePosition | null | ||
entryPosition | NodePosition | null | ||
vertices | NodePosition[] | null |
LineSettings
Name | Type | Required | Description |
---|---|---|---|
type | LineType | ||
curveType | CurveType |
DecoratorCell
extends BaseCell
Name | Type | Required | Description |
---|---|---|---|
type | "decorator" | ✅ | |
decorator | DecoratorType | ✅ | |
id | NodeId | ✅ | |
view | DecoratorView | ✅ |
DecoratorView
extends NodeView
Name | Type | Required | Description |
---|---|---|---|
text | string | ||
direction | Direction |
LayoutOptionsManual
extends LayoutSnapOptions
Name | Type | Required | Description |
---|
LayoutSnapOptions
Name | Type | Required | Description |
---|---|---|---|
snap | boolean | SnapOptions | Snap options. Setting to true means enable all snap options |