Skip to content

Commit 16e0580

Browse files
committed
Refactoring: Transfer nodes position as dictionary instead of array.
1 parent 6443998 commit 16e0580

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/dgmlManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ export class DgmlManager {
7171
}
7272
}
7373

74-
public addNodesAndLinks(xmlDoc: Document, nodes: Node[], nodeInfos: NetworkNode[], edges: Edge[]) {
75-
const nodeInfoDictionary = Object.assign({}, ...nodeInfos.map((nodeInfo) => ({ [nodeInfo.id]: nodeInfo })));
74+
public addNodesAndLinks(xmlDoc: Document, nodes: Node[], nodeInfoDictionary: { [id: string]: NetworkNode}, edges: Edge[]) {
7675
const nodesElement = this.addNodeToRoot(xmlDoc, "Nodes");
7776
const linksElement = this.addNodeToRoot(xmlDoc, "Links");
7877
const categoryDictionary: { [nodeType: string]: Category } = {};

templates/showHierarchy_Template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@
247247
}
248248

249249
function saveAsDgml() {
250-
const nodeExport = [];
250+
const nodeExport = {};
251251
nodes.forEach(node => {
252-
nodeExport.push({
252+
nodeExport[node.id] = {
253253
id: node.id,
254254
label: cleanLabel(node.label),
255255
position: network.getPosition(node.id),
256256
boundingBox: network.getBoundingBox(node.id)
257-
});
257+
};
258258
});
259259
const direction = hierarchicalOptionsDirectionSelect.value ? hierarchicalOptionsDirectionSelect.value : 'UD';
260260
vscode.postMessage({

0 commit comments

Comments
 (0)