Skip to content

Commit 973c705

Browse files
committed
click to focus on node
1 parent 7b047b2 commit 973c705

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

app/containers/Inspect.jsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ const Inspect = () => {
1313
.onChange(orientation => graph && graph.dagMode(orientation));
1414

1515
// graph config
16-
const NODE_REL_SIZE = 3;
16+
const NODE_REL_SIZE = 5;
1717
const graph = ForceGraph3D()
18+
.width(1000)
19+
.height(500)
1820
.dagMode('td')
1921
.dagLevelDistance(50)
2022
.backgroundColor('#101020')
@@ -26,8 +28,9 @@ const Inspect = () => {
2628
.nodeAutoColorBy('module')
2729
.nodeOpacity(0.9)
2830
.linkDirectionalParticles(2)
29-
.linkDirectionalParticleWidth(0.8)
31+
.linkDirectionalParticleWidth(1)
3032
.linkDirectionalParticleSpeed(0.006)
33+
.linkWidth(5)
3134
.d3Force('collision', d3.forceCollide(node => Math.cbrt(node.size) * NODE_REL_SIZE))
3235
.d3VelocityDecay(0.3);
3336

@@ -63,9 +66,14 @@ const Inspect = () => {
6366
}
6467
});
6568

66-
const elem = document.getElementById('graph');
67-
const Graph = ForceGraph3D()
68-
(elem)
69+
70+
graph(document.getElementById('graph'))
71+
.graphData({ nodes, links })
72+
.onNodeDragEnd(node => {
73+
node.fx = node.x;
74+
node.fy = node.y;
75+
node.fz = node.z;
76+
})
6977
.onNodeClick(node => {
7078
// Aim at node from outside it
7179
const distance = 40;
@@ -75,23 +83,14 @@ const Inspect = () => {
7583
? { x: node.x * distRatio, y: node.y * distRatio, z: node.z * distRatio }
7684
: { x: 0, y: 0, z: distance }; // special case if node is in (0,0,0)
7785

78-
Graph.cameraPosition(
86+
graph.cameraPosition(
7987
newPos, // new position
8088
node, // lookAt ({ x, y, z })
8189
3000 // ms transition duration
8290
);
8391
});
8492

8593

86-
graph(document.getElementById('graph'))
87-
.graphData({ nodes, links })
88-
.onNodeDragEnd(node => {
89-
node.fx = node.x;
90-
node.fy = node.y;
91-
node.fz = node.z;
92-
})
93-
94-
9594
});
9695
}, []);
9796

app/stylesheets/Inspect.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ h2 {
22
display: flex;
33
justify-content: center;
44
align-items: center;
5+
}
6+
7+
#graph {
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
511
}

0 commit comments

Comments
 (0)