-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsigma_layout_and_render.html
142 lines (116 loc) · 2.61 KB
/
sigma_layout_and_render.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<meta charset="utf-8">
<script src="third_party/sigma.js/build/sigma.min.js"></script>
<script src="third_party/sigma.js/build/plugins/sigma.layout.forceAtlas2.min.js"></script>
<script src="third_party/sigma.js/build/plugins/sigma.layout.noverlap.min.js"></script>
<script src="third_party/sigma.js/build/plugins/sigma.plugins.animate.min.js"></script>
<script src="https://turbo.github.io/js/turbo.js"></script>
<script src="sigma.layout.fruchtermanReingold.js"></script>
<script src="sigma.layout.paragraphl.js"></script>
<script src="data/grqc_auto.js"></script>
<style>
#webgl {
top: 20px;
bottom: 0;
left: 50px;
right: 0;
color: #000;
background: #fff;
position: absolute;
}
#layout {
top: 0;
left: 0;
position: fixed;
}
.label {
position: absolute;
top: 10px;
left: 10px;
z-index: 1;
font-family: sans-serif;
}
#timing {
left: 0px;
position: fixed;
}
</style>
<div id="container">
<div id="webgl">
<button id="layout" type="button">Layout</button>
<p id="timing"></p>
</div>
</div>
<script>
var i,
N = 100,
E = 500,
s = new sigma(),
cam = s.addCamera();
// Initialize two distinct renderers, each with its own settings:
s.addRenderer({
container: document.getElementById('webgl'),
type: 'webgl',
camera: cam,
settings: {
defaultLabelColor: '#000',
defaultNodeColor: '#666',
defaultEdgeColor: '#999',
edgeColor: 'default',
drawLabels: false
}
});
graph.nodes.map(function(d){
s.graph.addNode({
id: d.id,
label: 'Node ' + d.id,
x: d.id % 97,
y: d.id % 31,
size: 0
});
})
graph.links.map(function(d, t) {
s.graph.addEdge({
id: 'e' + t,
source: d.source,
target: d.target,
size: 1
});
})
s.refresh();
var force = false;
document.getElementById('layout').onclick = function() {
if (!force) {
console.log('Start layout');
s.startForceAtlas2({slowDown: 10});
}
else {
console.log('Stop layout');
s.stopForceAtlas2();
}
force = !force;
};
/*
// Start the algorithm:
var config = {
iterations : 100
};
var duration = 0.0;
var listener = sigma.layouts.fruchtermanReingold.configure(s, config);
// Bind all events:
var start_time;
listener.bind('start stop', function(event) {
console.log(event.type);
if (event.type == 'start') {
start_time = performance.now();
}
else {
var end_time = performance.now();
duration += end_time - start_time;
document.getElementById('timing').innerText = duration + ' ms';
console.log(duration);
}
});
sigma.layouts.fruchtermanReingold.start(s);
*/
</script>