Skip to content

Commit 72c4750

Browse files
committed
Bugfix: Edges no longer overlap if two nodes have mutual edges.
Updating package.json and changelog. Resolves #112
1 parent 8f5b7bd commit 72c4750

File tree

6 files changed

+61
-45
lines changed

6 files changed

+61
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Version 1.3.3
4+
5+
- Bugfix: When edges have the same source and target the edges no longer overlap.
6+
37
## Version 1.3.2
48

59
- When the mouse pointer is hovering over a node or an edge a popup is shown with various information about the node or edge.

package-lock.json

Lines changed: 45 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "DGMLViewer",
55
"description": "DGMLViewer is viewer for dgml (Directed Graph Markup Language) files",
66
"icon": "icon.png",
7-
"version": "1.3.2",
7+
"version": "1.3.3",
88
"repository": "https://github.com/CoderAllan/vscode-dgmlviewer",
99
"engines": {
1010
"vscode": "^1.55.0"

src/dgmlParser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ export class DgmlParser {
169169
if (newLink.category === undefined) {
170170
newLink.category = this.createCategoryRef(xmlNode);
171171
}
172+
const mutualLinks = links.filter(l => l.target === newLink.source && l.source === newLink.target);
173+
if (mutualLinks.length > 0) {
174+
newLink.mutualLinkCount += 1;
175+
mutualLinks.forEach(l => l.mutualLinkCount += 1 );
176+
}
172177
links.push(newLink);
173178
}
174179
});

src/model/Link.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BaseElement } from './BaseElement';
44
export class Link extends BaseElement {
55
public source: string | undefined;
66
public target: string | undefined;
7+
public mutualLinkCount: number = 1;
78
public category: string | undefined;
89
// CommonAttributes
910
public label: string | undefined;
@@ -42,6 +43,11 @@ export class Link extends BaseElement {
4243
jsStringProperties.push(`to: "${this.target}"`);
4344
titleElements.push(`Target: ${this.target}`);
4445
}
46+
if (this.mutualLinkCount > 1) {
47+
jsStringProperties.push(`smooth: {type: 'curvedCW', roundness: 0.2}`);
48+
} else {
49+
jsStringProperties.push(`smooth: false`);
50+
}
4551
if (this.strokeThickness !== undefined) { jsStringProperties.push(`width: ${this.strokeThickness}`); }
4652
if (this.visibility !== undefined) { jsStringProperties.push(`hidden: ${this.visibility}`); }
4753
const jsStringColorProperties: string[] = [];

templates/dgmlViewer_Template.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
interaction: {
2525
hover: true
2626
},
27-
edges: {
28-
smooth: false // Make edges straight lines.
29-
},
3027
nodes: {
3128
shape: 'box' // The shape of the nodes.
3229
},

0 commit comments

Comments
 (0)