From fb91fc90c7674af074b13f316e0d1d1338b39622 Mon Sep 17 00:00:00 2001 From: Utsob Roy Date: Thu, 2 Feb 2023 11:16:45 +0600 Subject: [PATCH] better zooming --- src/site/_includes/components/graphScript.njk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/_includes/components/graphScript.njk b/src/site/_includes/components/graphScript.njk index f7185db..d6df231 100644 --- a/src/site/_includes/components/graphScript.njk +++ b/src/site/_includes/components/graphScript.njk @@ -93,7 +93,7 @@ .onNodeClick(node => { window.location = node.url; }); - if (delay != null) { + if (delay != null && graphData.nodes.length > 2) { setTimeout(() => { Graph.zoomToFit(5, 75); }, delay); @@ -104,7 +104,7 @@ function fetchGraphData() { fetch('/graph.json').then(res => res.json()).then(data => { window.graphData = data; - Graph = renderGraph(filterToDepth(JSON.parse(JSON.stringify(data))), "link-graph", 330, 330); + Graph = renderGraph(filterToDepth(JSON.parse(JSON.stringify(data))), "link-graph", 330, 330, 1); }); } @@ -119,7 +119,7 @@ Graph._destructor(); Graph = null; } - renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 330, 330, null); + renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 330, 330, 1); }) window.fullGraph = null;