-
Notifications
You must be signed in to change notification settings - Fork 6
/
timeseries.html
138 lines (122 loc) · 3.37 KB
/
timeseries.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Map gardening linecharts</title>
<script src="d3/d3.v3.min.js" charset="utf-8"></script>
<script src="d3/queue.v1.min.js" charset="utf-8"></script>
<link href="gardening_charts.css" rel="stylesheet" />
</head>
<body>
<h1>OSM user activity over time: nodes edited per month</h1>
<div id="chart"></div>
<script src="gardening_lines.js"></script>
<script type="text/javascript">
var places = [
"amsterdam",
"auckland",
//"barcelona", // new city, needs population and area
"bayarea",
"berlin",
"boston",
"buenosaires",
"cairo",
//"chicago", // new city, needs population and area
//"crimea",
//"cyprus",
//"douala",
"haiti",
"istanbul",
"jakarta",
//"jerusalem",
//"kathmandu", // new city, needs population and area
//"lasvegas", // new city, needs population and area
"london",
"losangeles",
"manchester",
"mexicocity",
//"miami", // new city, needs population and area
"minsk",
"montevideo",
"montreal",
"moscow",
"mumbai",
"nairobi",
"newyork",
"quebec",
"paris",
"rio",
"santiago",
"seattle",
"seoul",
//"sydney", // new city, needs population and area
//"tirana",
"tokyo",
"toronto",
"vancouver"
//"yaounde"
];
var places = ["london"];
/*
var places = [
"bayarea",
"seattle",
"newyork",
"boston"
];
var places = [
"toronto",
"montreal",
"quebec",
"vancouver",
];
*/
var metadata = {};
d3.csv("userstats/places_metadata.csv", function(d) {
// do the parsing
return {
place: d.place,
population: +d.population,
bounds_area: +d.bounds_area,
land_area: +d.land_area
};
}, function(error, rows) {
if (error) {
console.log("error", error);
} else {
rows.forEach(function(d) {
metadata[d.place] = {};
metadata[d.place]['population'] = d.population;
metadata[d.place]['bounds_area'] = d.bounds_area;
metadata[d.place]['land_area'] = d.land_area;
});
}
});
var q = queue();
//places.forEach(function(place) { q.defer(d3.tsv, "userstats/userstats_" + place + ".csv");});
places.forEach(function(place) {
q.defer(d3.tsv, "userstats/combined_" + place + "_raster_1000m.tsv");
});
q.awaitAll(ready);
function ready(error, datasets) {
if (error) {
// Do more here
console.log("Error loading file");
} else {
setX('date')
setY('count-linear')
userstats = [];
for (var i = 0; i < places.length; i++) {
// for each row, add the placename. Must be a better way to do this.
// For the "userstats" files
datasets[i].forEach(function(d) {
d.place = places[i];
userstats.push(d);
});
}
createTimelines(userstats,metadata,true,true,true,false);
}
}
</script>
</body>
</html>