From 2f27bf43cc038ce36a2c69951232349cf7eee4cb Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Fri, 6 Aug 2021 08:58:01 +0200 Subject: [PATCH] feat(Vis View): :sparkles: Add height property to adjList Items --- src/VisModal.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/VisModal.ts b/src/VisModal.ts index 213c1c6a..62e0a429 100644 --- a/src/VisModal.ts +++ b/src/VisModal.ts @@ -99,6 +99,9 @@ export function dfsAdjList(g: Graph, startNode: string): AdjListItem[] { }); } } + const maxDepth = adjList.sort((a, b) => a.depth - b.depth).last().depth; + adjList.forEach((item) => (item.height = maxDepth - item.depth)); + return adjList; } @@ -132,15 +135,10 @@ export function bfsAdjList(g: Graph, startNode: string): AdjListItem[] { }); } } - return adjList; -} - -export function reverseDepth(adjList: AdjListItem[]) { - const copy = _.cloneDeep(adjList); - const maxDepth = copy.sort((a, b) => a.depth - b.depth).last().depth; + const maxDepth = adjList.sort((a, b) => a.depth - b.depth).last().depth; + adjList.forEach((item) => (item.height = maxDepth - item.depth)); - copy.forEach((item) => (item.depth = maxDepth - item.depth)); - return copy; + return adjList; } export const stratify = d3 @@ -169,7 +167,7 @@ export class VisModal extends Modal { let { contentEl } = this; contentEl.empty(); - contentEl.style.width = `${Math.round(window.innerWidth / 1.5)}px`; + contentEl.style.width = `${Math.round(window.innerWidth / 1.3)}px`; contentEl.style.height = `${Math.round(window.innerHeight / 1.3)}px`; const optionsDiv = contentEl.createDiv({ cls: "vis-view-options" });