Skip to content

Commit 0d9e2ea

Browse files
committed
Node position is now included when saving as dot file.
1 parent 9e5fb5c commit 0d9e2ea

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/graphvizManager.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@ import { Edge, NetworkNode, Node, Position } from "@model";
33
export class GraphVizManager {
44

55
public createGraphVizDiagram(graphType: string, nodes: Node[], nodeInfoDictionary: { [id: string]: NetworkNode }, edges: Edge[]): string {
6-
const maxX = Math.max(...Object.keys(nodeInfoDictionary).map(id => nodeInfoDictionary[id].position.x));
7-
const minX = Math.min(...Object.keys(nodeInfoDictionary).map(id => nodeInfoDictionary[id].position.x));
8-
const diffX = Math.max(...[Math.abs(maxX),Math.abs(minX)]);
9-
const maxY = Math.max(...Object.keys(nodeInfoDictionary).map(id => nodeInfoDictionary[id].position.y));
10-
const minY = Math.min(...Object.keys(nodeInfoDictionary).map(id => nodeInfoDictionary[id].position.y));
11-
const diffY = Math.max(...[Math.abs(maxY),Math.abs(minY)]);
12-
136
nodes.forEach(node => {
147
if(node.id in nodeInfoDictionary){
158
const networkNode = nodeInfoDictionary[node.id];
169
if (networkNode.label) {
1710
node.name = networkNode.label;
1811
}
1912
if (node.id in nodeInfoDictionary) {
20-
node.position = {x: Math.round(((networkNode.position.x + diffX) / maxX) * nodes.length), y: Math.round(((networkNode.position.y + diffY) / maxY) * nodes.length)};
13+
node.position = { x: networkNode.position.x, y: -1 * networkNode.position.y};
2114
}
2215
}
2316
});

src/model/Node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class Node {
6666
if (this.position !== undefined) {
6767
const x = this.position.x;
6868
const y = this.position.y;
69-
attributes.push(`pos="${x},${y}!"`);
69+
attributes.push(`pos="${x},${y}"`);
7070
}
7171
let attributesStr: string = '';
7272
if (attributes.length > 0) {

0 commit comments

Comments
 (0)