-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment_2.html
84 lines (64 loc) · 2.09 KB
/
assignment_2.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
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
// Set up on-load initialization
d3.select(window).on('load', init);
// Define data
var dataset = [];
var dataset0 = d3.csv("example_1_-_station.csv",
function(data) {
dataset0 = data.map(function(d) { return [+d["metANN"],+d["YEAR"] ]; });
//dataset = dataset.slice(0, 25)
for (i = 0; i < dataset0.length; i=i+9) {
dataset.push(dataset0[i]);
}
console.log(dataset);
});
// Initialiation function. Called after body has loaded
function init() {
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class", "bar")
.style("height", function(d) {
var barHeight = d[0] * 50
if (d[0] > 100) {
var barHeight = 0
}
return barHeight + "px";})
.text(function(d) { return d[0]+"C";})
.append('p')
.text(function(d) { return d[1];})
}
</script>
<meta charset="utf-8">
<title>D3 Page Template</title>
<style>
div.bar {
display: inline-block;
width: 80px;
height: 75px; /* Gets overriden by D3-assigned height below */
margin-right: 4px;
margin-bottom:5px;
background-color: cadetblue;
color:white;
vertical-align: bottom;
text-align:center;
}
//#plotarea {
//width:auto;
//height:auto;
//border:1px solid grey;
//}
//#plotarea circle {
//fill:red;
//}
</style>
</head>
<body>
<h2>Average Temperature in Geneva 1880-2015 (9-year steps displayed) </h2>
</body>
</html>