-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.html
50 lines (47 loc) · 1.7 KB
/
static.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
<html>
<head>
<style type="text/css">
#container {
max-width: 400px;
height: 400px;
margin: auto;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="sigma.min.js"></script>
<script src="sigma.parsers.json.min.js"></script>
<script src="transformer.js"></script>
<script src="jquery.js"></script>
<script>
var input = {"nodes":[{"id":"n0","label":"Node 0","x":2,"y":2,"size":3},{"id":"n1","label":"Node 1","x":1,"y":1,"size":3},{"id":"n3","label":"Node 3","x":1.5,"y":1,"size":3},{"id":"n4","label":"Node 4","x":2,"y":1,"size":3},{"id":"n5","label":"Node 5","x":2.5,"y":1,"size":3},{"id":"n2","label":"Node 2","x":0,"y":0,"size":3},{"id":"n6","label":"Node 6","x":0.5,"y":0,"size":3}],"edges":[{"id":"e0","source":"n0","target":"n1"},{"id":"e3","source":"n0","target":"n3"},{"id":"e4","source":"n0","target":"n4"},{"id":"e5","source":"n0","target":"n5"},{"id":"e1","source":"n1","target":"n2"},{"id":"e6","source":"n1","target":"n6"}]};
var s;
function clickHandler(e){
$("body").html("");
$("body").append("<div id='container'></div>");
s = new sigma({
graph: dataTree.getSubtree(e.data.node),
container: 'container',
settings: {
defaultNodeColor: '#ec5148'}
});
s.bind('clickNode', clickHandler);
console.log(e.type, e.data.node.label, e.data.captor);
}
$(document).ready(function(){
var dataTree = new Tree(sample);
dataTree.analyse();
dataTree.generateCoordinates();
console.log(dataTree.getGraph());
s = new sigma({
graph: dataTree.getSubtree(),
container: 'container',
settings: {
defaultNodeColor: '#ec5148'
}});
s.bind('clickNode', clickHandler);
});
</script>
</body>
</html>