1、重写 PolylineEdgeModel 类(其它 EdgeModel 都可以)
`class CustomNetWorkNodeEdge extends PolylineEdge { }
class CustomNetWorkNodeEdgeModel extends PolylineEdgeModel {
getData() {
const data = super.getData();
//获取开始锚点自定义属性添加到Edge (“cousetomType” 为 Anchor 锚点上自定义的key)
data["fromAnchorType"] = this.getBeginAnchor(this.sourceNode,this.targetNode,this.sourceAnchorId).cousetomType;
return data;
}
}
export const customNetWorkEdge = {
type: "coustom_edge",
view: CustomNetWorkNodeEdge,
model: CustomNetWorkNodeEdgeModel
};
2、判断节点是否使用自定义 edge
lf = new LogicFlow({
container: document.getElementById("container"),
// 其他配置
grid: true,
plugins: [Menu],
edgeGenerator: (sourceNode, targetNode, currentEdge) => {
/**
* 起始节点类型 netWork时使用 自定义的边 coustom_edge;
* */
if (sourceNode.type === "netWork") return "coustom_edge"
}
})
3、注册到 lf
lf.register(customNetWorkEdge)
连线时在 ”coustom_edge“ 上会添加锚点数据中自定义的key值