Skip to content

Commit

Permalink
Adjust d3 forces #15 will make component controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 20, 2024
1 parent 2d373e8 commit 35a9bdc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions templates/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,11 @@

// # Add forces to the graph
// Dynamic collision radius based on node type
Graph.d3Force('collide', d3.forceCollide().radius(node => {
if (node.type === 'instance') {
return instanceSizeMultiplier;
}
return avatarSizeMultiplier / 2 + 7 * Math.sqrt(node.connectionCount);
}))
// Increased charge strength for better separation
Graph.d3Force('collide', d3.forceCollide().radius(node => node.type === 'instance' ? 60 : 42))
// Increased repulsive force
.d3Force('charge', d3.forceManyBody().strength(-42000))
// Increased distance and adjusted strength for links
.d3Force('link', d3.forceLink().id(d => d.id).distance(200).strength(0.5))
// Center the graph in the middle of the container
.d3Force('x', d3.forceX(container.clientWidth / 2).strength(0.05))
.d3Force('y', d3.forceY(container.clientHeight / 2).strength(0.05))
.d3Force('center', d3.forceCenter(container.clientWidth / 2, container.clientHeight / 2))
Expand Down

0 comments on commit 35a9bdc

Please sign in to comment.