-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
76 lines (61 loc) · 2.1 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
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>d3.punchcard</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>D3.js Timecard/GitHub-style viz</h1>
<h2>Carl V. Lewis</h2>
<h4>Built as a way to track volunteer hours for <a href="http://opensavannah.org">Open Savannah</a></h4>
<div id="example"></div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.3.11/d3.min.js"></script>
<script src="d3.timecard.js"></script>
<script>
d3.csv(
'data.csv',
// parsing function
function(d) {
return d3.entries(d);
},
// callback function
function(data) {
showGraph(data);
}
)
function showGraph(data) {
var flatAscending,
upperLimit,
examplePunchcard;
flatAscending = data.map(function(array) {
var value;
return array.slice(1).map(function(sliced) {
return parseFloat(sliced.value);
}).filter(function(element) {
return element > 0;
});
}).reduce(function(a, b) {
return a.concat(b);
}).sort(function(a, b) {
return a - b;
});
// we find the upper limit quantile in order
// to not show upper outliers
upperLimit = d3.quantile(flatAscending, 0.95);
examplePunchcard = new D3punchcard({
data: data,
element: '#example',
upperLimit: upperLimit
})
.draw({
width: document.getElementById('example').offsetWidth
});
}
</script>
</body>
</html>