-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
72 lines (63 loc) · 2.13 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SO Clones</title>
<link rel="stylesheet" type="text/css" href="global.css"/>
<script src="lib/d3/d3.js"></script>
</head>
<body>
<script>
d3.csv("data/index.csv", function (row, index) {
return {
Row: index+1,
HashValue: row.HashValue,
Sample: row.Sample,
PostCount: parseInt(row.PostCount),
ThreadCount: parseInt(row.ThreadCount),
LineCount: parseInt(row.LineCount)
}
}).then(function(data) {
// see also http://bl.ocks.org/jfreels/6734025
var columns = ["Row", "HashValue", "Sample", "PostCount", "ThreadCount", "LineCount"];
var column_alignment = ["align-right", "align-right", "align-right", "align-right", "align-right", "align-right"];
var table = d3.select('body')
.append('table')
.attr("cellspacing", 5);
var thead = table.append('thead');
var tbody = table.append('tbody');
// add table header
thead.append('tr')
.selectAll('th')
.data(columns)
.enter()
.append('th')
.text(function(column) { return column; });
// create table rows
var rows = tbody.selectAll('tr')
.data(data)
.enter()
.append('tr');
// create a cell in each row for each column
var cells = rows.selectAll('td')
.data(function(row) {
return columns.map(function(column) {
return {column: column, value: row[column]};
});
})
.enter()
.append('td')
.html(function(d) {
if (d.column === "HashValue") {
return "<a target='_blank' href='snippet-view.html?hashValue=" + d.value + "'>" + d.value + "</a>";
} else {
return d.value;
}
})
.attr("class", function(d) {
return column_alignment[columns.indexOf(d.column)];
});
});
</script>
</body>
</html>