-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
60 lines (44 loc) · 1.31 KB
/
index.js
File metadata and controls
60 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function getGraphDataSets() {
const loadData = function(Graph) {
Graph
.cooldownTicks(0)
.nodeLabel('id')
.nodeAutoColorBy('group')
.forceEngine('d3')
.graphData(data)
.enableNodeDrag(false)
};
return loadData
}
const Graph = ForceGraph3D({
extraRenderers: [new THREE.CSS2DRenderer()]
})
(document.getElementById("3d-graph"))
let curDataSetIdx;
const dataSets = getGraphDataSets();
let toggleData;
(toggleData = function() {
curDataSetIdx = curDataSetIdx === undefined ? 0 : (curDataSetIdx+2)%dataSets.length;
const dataSet = dataSets[curDataSetIdx];
Graph.resetProps(); // Wipe current state
dataSets(Graph); // Load data set
})();
// function for the is checked option
function isChecked() {
if(document.getElementById("my-checkbox").checked){
Graph.resetProps();
Graph.nodeThreeObject(node => {
const nodeE1 = document.createElement('div');
nodeE1.textContent = node.id;
nodeE1.style.color = node.color;
nodeE1.className = 'node-label';
return new THREE.CSS2DObject(nodeE1);
});
Graph.nodeThreeObjectExtend(true);
dataSets(Graph);
}
else{
Graph.resetProps();
dataSets(Graph);
}
}