From ccbdf2f22e9c63075f61c433f4030718eaadcaba Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Fri, 6 Aug 2021 08:46:18 +0200 Subject: [PATCH] refactor(Vis View): :construction: Porgress on tidyTree --- src/Visualisations/TidyTree.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Visualisations/TidyTree.ts b/src/Visualisations/TidyTree.ts index 07bb2cf4..c91a3d98 100644 --- a/src/Visualisations/TidyTree.ts +++ b/src/Visualisations/TidyTree.ts @@ -16,6 +16,14 @@ export const tidyTree = ( const adjList: AdjListItem[] = bfsAdjList(graph, currFile.basename); console.log({ adjList }); + const noDoubles = [...adjList]; + noDoubles.forEach((a, i, list) => { + if (list.some((b, j) => i !== j && a.parentId === b.parentId)) { + noDoubles.splice(i, 1); + } + }); + console.log({ noDoubles }); + const tree = (data) => { const root = d3.hierarchy(data); root.dx = 10; @@ -23,7 +31,7 @@ export const tidyTree = ( return d3.tree().nodeSize([root.dx, root.dy])(root); }; - const root = tree(stratify(adjList)); + const root = tree(stratify(noDoubles)); console.log(root); let x0 = Infinity;