-
Notifications
You must be signed in to change notification settings - Fork 0
/
glee_visualize.js
76 lines (76 loc) · 1.94 KB
/
glee_visualize.js
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
var show = [];
var vis = new pv.Panel()
.width(1250)
.height(500)
.bottom(90);
var files = [];
var links = [];
var nodes = [];
function generateFiles() {
files = [];
for(var i = 0; i < filecounts.length; i++)
{
files.push(filecounts[i].file.replace("/Users/wxstamper/github/iron/client/public/","").replace(".coffee",""));
}
}
function generateLinks() {
links = [];
for(var i = 0; i < filecounts.length; i++)
{
for(var j = 0; j < filecounts[i].counts.length; j++)
{
var s = i;
var t = files.indexOf(filecounts[i].counts[j].path);
var v = Number(filecounts[i].counts[j].count);
if(v==0)
{
console.log(files[i].substring(files[i].lastIndexOf("/")+1) + " imports " + filecounts[i].counts[j].name + " for no reason...");
}
else if(t!=-1)
{
links.push({"source":s, "target":t, "value":v});
}
}
}
}
function generateNodes() {
nodes = [];
for(var i = 0; i < files.length; i++)
{
var temp = files[i].replace("_view_controller","");
nodes.push({"nodeValue":temp.substring(temp.lastIndexOf("/")+1)});
}
}
generateFiles();
generateLinks();
generateNodes();
var arc = null;
var nodeMark = null;
var labels = null;
var linkMarks = null;
function drawArcs() {
arc = vis.add(pv.Layout.Arc)
.nodes(nodes)
.links(links)
.sort(function(a,b) a.nodeValue > b.nodeValue
?1
:-1)
}
drawArcs();
linkMarks = arc.link.add(pv.Line)
.strokeStyle(function(d) {
return (show.indexOf(d.index)==-1)?"rgba(0, 0, 0, 0)":"rgba(0, 0, 255, 0.5)"
})
labels = arc.label.add(pv.Label)
nodeMarks = arc.node.add(pv.Dot)
.size(function(d) d.linkDegree + 10 )
.fillStyle(pv.Colors.category19().by(function(d) d.group))
.strokeStyle(function() this.fillStyle().darker())
.event("click", function() {
if(show.indexOf(this.index)==-1)
show.push(this.index);
else
show.splice(show.indexOf(this.index),1);
linkMarks.render();
});
vis.render();