-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
112 lines (82 loc) · 2.28 KB
/
index.html
File metadata and controls
112 lines (82 loc) · 2.28 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<html>
<head>
<title>Stop, go, continue</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
var svg_data;
// function fetch(){
// setInterval(function(){
// $.getJSON('http://localhost:3000', function(data){
// svg_data = data;
// });
// }, 3000);
// }
// fetch();
// dummy data
svg_data = [{text: "Wedensday drinks! #continue", rt:"4"},{text: "Removing the door #go", rt:"15"},{text: "Thursday drinks! #continue", rt:"9"},{text: "Keeping the door open #cotinue", rt:"5"}, {text: "Friday drinks! #continue", rt:"13"},{text: "Keeping the door open #stop", rt:"11"},{text: "Morning challenges #go", rt:"2"} ]
length = svg_data.length;
var barPadding = 20;
var h = 200;
var w = 500;
var barPadding = 20;
var svg = d3.select("body")
.append("svg")
.attr({
width: w,
height: h,
});
var svg2 = d3.select("body")
.append("svg")
.attr({
width: w,
height: h,
y: 210
});
var texts = svg2.selectAll("text")
.data(svg_data)
.enter()
.append("text")
.attr("x", function(d,i){ return 25;})
.attr("y", function(d,i){ return i * ( h/length) + 20})
.text(function(d){ return (d.text + " " + d.rt)});
var rects = svg.selectAll("rect")
.data(svg_data)
.enter()
.append("rect")
.attr("fill", function (d) { return "rgb(0, 0, " + (d.rt * 20) + ")" ;});
rects.attr("x", function(d, i) {
return i * ( w/length );
})
.attr("y", function(d) {
return h - (d.rt * 5);
})
.attr("width", function(d){ return w/length})
.attr("height", function(d) {
return d.rt * 5;
});
/*
var circles = svg.selectAll("circle")
.data(svg_data)
.enter()
.append("circle");
circles.attr("cx", function(d, i) {
return 30;
})
.attr("cy", function(d,i){ return i * 50 + 20})
.attr("r", function(d) {
console.log(d.rt);
return d.rt;
})
.attr("fill", "black")
.attr("stroke-width", function(d) {
return d/2;
});
*/
});
</script>
</body>
</html>