Skip to content

Commit

Permalink
#1 use force
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent d899492 commit bc28b94
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions templates/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
const graphData = {{ graph_data | tojson }};

const Graph = ForceGraph()(document.getElementById('graph'))
.graphData(graphData)
.nodeLabel(node => node.username)
.onNodeClick(node => console.log(node));

.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));

Graph.onEngineStop(() => Graph.zoomToFit(400));
</script>

0 comments on commit bc28b94

Please sign in to comment.