-
Notifications
You must be signed in to change notification settings - Fork 1
/
fa2_as_sigma_hack.html
110 lines (100 loc) · 3.67 KB
/
fa2_as_sigma_hack.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
<!DOCTYPE html>
<html>
<head>
<title>FA2 Sigma.</title>
<script type="text/javascript" src="js/vivagraph.js"></script>
<script type="text/javascript" src="js/fa2.supervisor.js"></script>
<script type="text/javascript" src="js/worker.js"></script>
<script type="text/javascript" src="js/helper.js"></script>
<script type="text/javascript" src="js/data.js"></script>
<link href="main.css" rel="stylesheet"/>
</head>
<body>
<div id="map" class="map-container"></div>
<div class="controller">
<input type="checkbox" id="cbForceAtlas2"/><label for="cbForceAtlas2">Toggle ForceAtlas2</label>
<br/>
<input type="checkbox" id="cbToggleSettings"/><label for="cbToggleSettings">Toggle Settings</label>
<div class="settings not-shown" id="settings">
<ul>
<li>
<label>linLogMode</label><input type="checkbox" id="linLogMode"/>
</li>
<li>
<label>outboundAttractionDistribution</label><input type="checkbox" id="outboundAttractionDistribution"/>
</li>
<li>
<label>adjustSizes</label><input type="checkbox" id="adjustSizes"/>
</li>
<li>
<label>edgeWeightInfluence</label><input type="number" step="any" value="0" id="edgeWeightInfluence"/>
</li>
<li>
<label>scalingRatio</label><input type="number" step="any" value="1" id="scalingRatio"/>
</li>
<li>
<label>strongGravityMode</label><input type="checkbox" id="strongGravityMode"/>
</li>
<li>
<label>gravity</label><input type="number" step="any" value="1" id="gravity"/>
</li>
<li>
<label>slowDown</label><input type="number" step="any" value="1" id="slowDown"/>
</li>
<li>
<label>barnesHutOptimize</label><input type="checkbox" id="barnesHutOptimize"/>
</li>
<li>
<label>barnesHutTheta</label><input type="number" step="any" value="0.5" id="barnesHutTheta"/>
</li>
<li>
<label>startingIterations</label><input type="number" value="1" id="startingIterations"/>
</li>
<li>
<label>iterationsPerRender</label><input type="number" value="1" id="iterationsPerRender"/>
</li>
</ul>
<button id="btnUpdateConfig">Update</button>
</div>
</div>
<script type="text/javascript">
var GraphCommons = GraphCommons || {};
(function() {
var graph = Viva.Graph.graph();
var layout = Viva.Graph.Layout.constant(graph, {});
var svgGraphics = Viva.Graph.View.svgGraphics();
GraphCommons.Helper.addData(graph);
var renderer = Viva.Graph.View.renderer(graph, {
container: document.getElementById('map'),
layout: layout,
graphics: svgGraphics
});
graph.forEachNode(function (node) {
var pos = layout.getNodePosition(node.id);
console.log(node.id, pos.x, pos.y);
});
renderer.run();
var sigma = new GraphCommons.ForceAtlas2.sigma({
graph: graph,
layout: layout,
renderer: renderer,
graphics: svgGraphics
});
// toggling force atlas algorithm
var cbForceAtlas2 = document.getElementById('cbForceAtlas2');
cbForceAtlas2.addEventListener('change', function() {
if (this.checked) {
console.log('starting fa2');
sigma.startForceAtlas2();
}
else {
console.log('stopping fa2');
sigma.stopForceAtlas2();
}
});
// updating algorithm parameters
GraphCommons.Helper.initSettings(sigma);
}(GraphCommons));
</script>
</body>
</html>