-
Notifications
You must be signed in to change notification settings - Fork 6
/
scatterlines.html
160 lines (137 loc) · 4.48 KB
/
scatterlines.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Map gardening scatterplots</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</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", // There's an error in my blankspot analysis for these cities. Skip for now
//"paris", // There's an error in my blankspot analysis for these cities. Skip for now
"rio",
"santiago",
"seattle",
"seoul",
"sydney", // new city, needs population and area
//"tirana",
"tokyo",
"toronto",
"vancouver"
//"yaounde"
];
//var places = ["planet"];
//var currentlySelected = "planet";
var currentlySelected = "bayarea";
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();
// Load one of these for each place
places.forEach(function(place) {
q.defer(d3.tsv, "userstats/outputv5_" + place + "_raster_1000m.tsv");
});
// Then one of these for each place
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 {
// set the initial state of the controls
updateX('date')
updateY('v1_ratio-linear')
//setX('date')
//setY('v1_ratio-linear')
//setR('days_active');
localness = [];
for (var i = 0; i < places.length; i++) {
// First we loop through the first set of files we loaded (the first half of the array)
// 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];
localness.push(d);
});
}
userstats = [];
for (var i = places.length; i < (2 * places.length); i++) {
// Now we loop through the second set of files we loaded (the second half of the array)
// 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 - places.length];
userstats.push(d);
});
}
createTimelines(userstats,metadata,localness,true,false,true,true,false,true,false);
updateCadence('monthly');
togglePlaces(false);
togglePlace(currentlySelected,true);
updateX('date')
updateY('v1_ratio-linear')
//not sure why I need to do this twice:
updateX()
updateY()
}
}
</script>
</body>
</html>