From 552de5ae51669475f672779c734deedc232c3b9f Mon Sep 17 00:00:00 2001 From: Scobiform Date: Wed, 17 Apr 2024 18:40:02 +0200 Subject: [PATCH] #1 d3 force --- templates/graph.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/graph.html b/templates/graph.html index dac5f65..2d3d3be 100644 --- a/templates/graph.html +++ b/templates/graph.html @@ -6,9 +6,12 @@ const Graph = ForceGraph()(document.getElementById('graph')) .graphData(graphData) .nodeLabel(node => node.username) - .force('charge', d3.forceManyBody().strength(-120)) // Adjust strength for repulsion or attraction - .force('link', d3.forceLink().id(d => d.id).distance(50)) // Adjust link distance .onNodeClick(node => console.log(node)); + // Configuration for forces if supported by the library + Graph.d3Force('charge', d3.forceManyBody().strength(-120)); + Graph.d3Force('link', d3.forceLink().distance(50)); + Graph.onEngineStop(() => Graph.zoomToFit(400)); + \ No newline at end of file