/
sameas-2009.html
68 lines (57 loc) · 1.63 KB
/
sameas-2009.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
<html>
<head>
<title>Force-Directed Layout</title>
<script type="text/javascript" src="protovis-r3.2.js"></script>
<script type="text/javascript" src="sameas-2009.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>
<script type="text/javascript+protovis">
function nodeColor(hostname) {
var parts = hostname.split(".");
var tld = parts[parts.length-1];
var other_tld = parts[parts.length-2];
if (tld == "org" || other_tld == "org")
return "lightgreen";
else if (tld == "com" || other_tld == "co")
return "yellow";
else if (tld == "gov" || other_tld == "gov")
return "orange";
else if (tld == "edu" || other_tld == "ac")
return "red";
else if (tld == "net" || other_tld == "net")
return "pink"
else
return "white";
}
var w = document.body.clientWidth,
h = document.body.clientHeight,
colors = pv.Colors.category19();
var vis = new pv.Panel()
.width(w)
.height(h)
.fillStyle("white")
.event("mousedown", pv.Behavior.pan())
.event("mousewheel", pv.Behavior.zoom());
var force = vis.add(pv.Layout.Force)
.nodes(sameas.nodes)
.links(sameas.links)
.bound(true)
.springConstant(0.05);
force.link.add(pv.Line);
force.node.add(pv.Dot)
.size(function(d) (d.linkDegree + 4) * Math.pow(this.scale, -1.5))
.fillStyle(function(d) nodeColor(d.nodeName))
.strokeStyle(function() this.fillStyle().darker())
.lineWidth(1)
.title(function(d) d.nodeName)
.event("mousedown", pv.Behavior.drag())
.event("drag", force);
vis.render();
</script>
</body>
</html>