-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
64 lines (51 loc) · 1.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>D3 Test</title>
<script type="text/javascript" src="d3/d3.v3.js"></script>
<style type="text/css">
div.bar {
display: inline-block;
width: 20px;
margin-right: 2px;
height: 75px; /* We'll override this later */
background-color: teal;
}
</style>
</head>
<body>
<script type="text/javascript">
// Your beautiful D3 code will go here
var dataset = [];
for (var i=0 ; i < 20 ; i++) {
var num = Math.random() * 30;
dataset = dataset.concat(num);
}
// d3.select("body").selectAll("p")
// .data(dataset)
// .enter()
// .append("p")
// .text(function(d) { return d; })
// .style("color", function(d) {
// if (d > 15) { //Threshold of 15
// return "red";
// } else {
// return "black";
// }
// });
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class", "bar")
.style("height", function(d) {
var barHeight = d * 5; //Scale up by factor of 5
return barHeight + "px";
});
setTimeout(function(){
window.location.reload(1);
}, 3000);
</script>
</body>
</html>