|
@@ -221,57 +221,56 @@ export const render = (graph: Graph, project: ProjectInfo) => {
|
|
|
}
|
|
|
});
|
|
|
relations.forEach((relation) => {
|
|
|
- if (!graph.getCellById(relation.id)) {
|
|
|
+ const relationEdge = graph.getCellById(relation.id);
|
|
|
+
|
|
|
+ if (!relationEdge) {
|
|
|
renderRelationEdge(relation);
|
|
|
- } else {
|
|
|
- const relationEdge = graph.getCellById(relation.id);
|
|
|
- if (relationEdge.isEdge()) {
|
|
|
- if (project.setting.showRelation) {
|
|
|
- // 更新标签
|
|
|
- relationEdge.setLabelAt(0, {
|
|
|
- attrs: {
|
|
|
- txt: {
|
|
|
- text:
|
|
|
- relation.relationType === RelationType.OneToOne ||
|
|
|
- relation.relationType === RelationType.OneToMany
|
|
|
- ? "1"
|
|
|
- : "n",
|
|
|
- },
|
|
|
- bg: {
|
|
|
- fill: relation.style?.color || "#333",
|
|
|
- }
|
|
|
- },
|
|
|
- position: {
|
|
|
- distance: 25,
|
|
|
+ } else if(relationEdge.isEdge()) {
|
|
|
+ if (project.setting.showRelation) {
|
|
|
+ // 更新标签
|
|
|
+ relationEdge.setLabelAt(0, {
|
|
|
+ attrs: {
|
|
|
+ txt: {
|
|
|
+ text:
|
|
|
+ relation.relationType === RelationType.OneToOne ||
|
|
|
+ relation.relationType === RelationType.OneToMany
|
|
|
+ ? "1"
|
|
|
+ : "n",
|
|
|
},
|
|
|
- });
|
|
|
- relationEdge.setLabelAt(1, {
|
|
|
- attrs: {
|
|
|
- txt: {
|
|
|
- text:
|
|
|
- relation.relationType === RelationType.OneToMany
|
|
|
- ? "n"
|
|
|
- : "1",
|
|
|
- },
|
|
|
- bg: {
|
|
|
- fill: relation.style?.color || "#333",
|
|
|
- }
|
|
|
- },
|
|
|
- position: {
|
|
|
- distance: -25,
|
|
|
+ bg: {
|
|
|
+ fill: relation.style?.color || "#333",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ position: {
|
|
|
+ distance: 25,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ relationEdge.setLabelAt(1, {
|
|
|
+ attrs: {
|
|
|
+ txt: {
|
|
|
+ text:
|
|
|
+ relation.relationType === RelationType.OneToMany
|
|
|
+ ? "n"
|
|
|
+ : "1",
|
|
|
},
|
|
|
- });
|
|
|
- } else {
|
|
|
- relationEdge.setLabels([]);
|
|
|
- }
|
|
|
- relationEdge.setAttrs({
|
|
|
- line: {
|
|
|
- stroke: relation.style?.color || "#333",
|
|
|
- strokeWidth: relation.style?.width || 1,
|
|
|
- strokeDasharray: dasharrayMap[relation.style?.lineType as RelationLineType || RelationLineType.Solid]
|
|
|
+ bg: {
|
|
|
+ fill: relation.style?.color || "#333",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ position: {
|
|
|
+ distance: -25,
|
|
|
},
|
|
|
});
|
|
|
+ } else {
|
|
|
+ relationEdge.setLabels([]);
|
|
|
}
|
|
|
+ relationEdge.setAttrs({
|
|
|
+ line: {
|
|
|
+ stroke: relation.style?.color || "#333",
|
|
|
+ strokeWidth: relation.style?.width || 1,
|
|
|
+ strokeDasharray: dasharrayMap[relation.style?.lineType as RelationLineType || RelationLineType.Solid]
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
};
|