/
gasEmit.html
376 lines (335 loc) · 10.4 KB
/
gasEmit.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<title>Population and Gas Emissions</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href=" https://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.1.3/css/jasny-bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.1.3/js/jasny-bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.js"></script>
<script src="script/d3/d3.v3.5.17.js"></script>
<script src="script/d3/sankey.js"></script>
</head>
<style>
<style>
body
{
background: green;
/* light gray: c2cbce light green: fbfef3 green-gray: d1d6c2 dde1d2 light green: d1ed70 */
min-height: 0px;
margin-top: 0px;
margin-bottom: 0px;
font-family: Avenir, Gill-Sans, Arial, Helvetica, sans-serif;
font-size: 16px;
}
p
{
font-family: Avenir, Gill-Sans, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.navbar {
margin-bottom: 0 !important;
/* Overrides white space under navbar */
}
#wrapperOutside
{
background: #ebf0e4;
/* f2ffe6 c1dee3 ddebdd edf5ee ebf0e4 */
}
#wrapperInside
{
margin:0 auto;
background: #fafdff;
/* light gray CCC e7e7e7 dadada fff5f7 faffff eaf5f4 edf7fa fafdff f5f6ff */
width:1200px;
height: 100%;
padding: 0px;
position: relative;
overflow: hidden;
}
#title
{
font-size: 44px;
position: absolute;
left: 80px;
top: 50px;
font-style: bold;
text-shadow: 0 1.0px 0 #fff;
}
#subtitle
{
font-size: 30px;
position: absolute;
left: 160px;
top: 120px;
color: #cb0000; /* darker red: C70039 brighter red: ea4b01 */
text-shadow: 0 1.6px 0.4px black;
font-style: italic;
}
.row
{
margin: 30px;
padding-top: 10px;
background-color: none;
}
#pubDate
{
font-family: Courier, Avenir, Gill-Sans, Arial, Helvetica, sans-serif;
font-size: 14px;
}
#author
{
font-style: italic;
font-size: 16px;
color: #1437c7; /* #38638f brighter blue: 164791 0334a6 1437c7 */
}
#bodyText
{
margin-top: 10px;
}
/* BEGIN: OF STYLE FOR: Block Quote */
@import url(https://fonts.googleapis.com/css?family=PT+Sans|Ubuntu:300,400,700);
.containerQuote {
background: #e6ecfa; /* light gray-green: fbfef3 d1d6c2 #f4fad7 mint green: aee3a1 bce0b8 daebd3 ccf0d0 #b0ffd5 aef5d6 b1f5de b8f2e4 c2f2ec e6ecfa */
width: 100%;
max-width: 480px;
min-width: 320px;
margin: 1em auto 0;
padding: 1.5em;
}
p { margin-bottom: 1.5em; }
p:last-child { margin-bottom: 0; }
blockquote {
display: block;
border-width: 2px 0; /* 2px 0 */
border-style: solid;
border-color: #1437c7; /* eee 1437c7 */
padding: 1.0em 0 1.0em;
margin: 0.7em 0;
position: relative;
}
blockquote:before {
content: '\201C';
position: absolute;
top: -0.22em;
left: -0.48em; /* left: 0%; */
transform: translate(-50%, -50%);
background: #fafdff; /* #fff #f4fad7 */
width: 3rem;
height: 2rem;
font: 6em/1.08em 'PT Sans', sans-serif;
color: #e6ecfa; /* #666 same green as background: ccf0d0 mint green: 88f5a5 b7f7cf b0ffd5 b1f5de b8f2e4 e6ecfa */
text-align: center;
}
blockquote:after {
content: '\201D'; /* "\2013 \2003" attr(cite) */
position: absolute;
bottom: -0.02em;
right: -0.77em; /* left: 0%; */
transform: translate(-50%, -50%);
background: #fafdff; /* #fff #f4fad7 */
width: 3rem;
height: 2rem;
font: 6em/1.08em 'PT Sans', sans-serif;
color: #e6ecfa;
text-align: center;
}
/* END: OF STYLE FOR: Block Quote */
#mySidebar
{
padding-top: 14px;
background-color: #f2f6fa; /* medium gray d8e1e6 f7f7f7 f2f6fa */
height: 82rem;
}
.myButton
{
color: blue;
}
/* MODAL */
.modal.in .modal-dialog {
width: 80vw !important;
}
.modal-content {
height: 80vh !important;
}
/* TABLE */
h1{
color: #0099FF;
}
tr{
background-color: #fafdff;
}
td, th {
background-color: gray;
font-size: 14px;
padding: 6px;
}
table{
color: #FFFFFF;
}
/* TAB NAVIGATION BAR on Top of Table and Map */
#tab_navigationBar
{
background-color: lavender;
height: 40px;
width: 100%;
}
.tab_navBar
{
float: left;
padding: 10px;
border: solid 1px #060606;
cursor: pointer;
}
.tab_navBar: hover
{
background-color: green;
color: white;
}
.tab_navBar.selected
{
background-color: purple;
}
</style>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Schraml Designs</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="http://trangdoanlam.com" target="_blank">Home</a></li>
<li><a href="http://trangdoanlam.com/data-binding" target="_blank">Data Binding</a></li>
<li><a href="http://trangdoanlam.com/maps" target="_blank">Maps</a></li>
<li class="active"><a href="gasEmit1.html">Emerging Landscape</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="form_contact.html"><span class="glyphicon glyphicon-user"></span> Contact</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
<form class="navbar-form navbar-right" action="/action_page.php">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" name="search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</nav>
<div id="wrapperOutside">
<div id="wrapperInside">
<div class="row"><!-- BEGINNING OF: Both Columns -->
<h2>Connecting the Dots: Population Density and Gas Emissions</h2>
<p>In an attempt to trace the connections between population and gas emissions (specifically from the Industrial Sector), let's focus on one region with known data such as Europe. Based on data from the EU, the map shows gas emissions by country, showing the geospatial reference between gas emissions and countries that are considered "industrial" or first world countries.</p>
<div id="tab_navigationBar">
</div>
<div class="col-sm-3" style="background-color:lavender;"><!-- BEGINNING OF: First Column of 1/3 // style="background-color:lavender;" -->
<div id="table"></div>
<div id="myDataText"></div>
</div>
<div class="col-sm-9" style="background-color:yellow;"><!-- BEGINNING OF: Second Column of 2/3 // style="background-color:lavender;" -->
<p>Map Showing Population</p>
</div>
</div>
</div> <!-- END OF: wrapperInside, for everything under the navigation bar -->
</div> <!-- END OF: wrapperOutside, for everything under the navigation bar -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<!-- Added d3 local file: version 3.5.6 -->
<script type="text/javascript" src="script/d3/d3.min.js"></script>
<script type="text/javascript">
//Load in contents of CSV file, and do things to the data.
d3.csv("data/water_improvement_data.csv", function(error, myData) {
if (error) {
console.log("Error loading water_improvement_data.csv");
}
// ----------------------------------------------------
// NOTE TO TRANG: THIS SECTION IS FOR TEXT
var myYears = ["2015", "1990"];
d3.select("#tab_navigationBar").selectAll(".tab_navBar")
.data(myYears)
.enter()
.append("div")
.attr("class", "tab_navBar")
.text( function(d) {
return d;
})
.classed("selected", false)
.on("click", function(d) {
d3.selectAll(".tab_navBar").classed("selected", false);
d3.select(this).classed("selected", true)
myTextByYear(d);
});
function myTextByYear(year) {
d3.selectAll(".myTextByYear")
.remove();
myData.forEach(function(d, i){
d3.select("#myDataText")
.append("div")
.attr("class", "myTextByYear")
.text( function(){
console.log("year" + year, d.year1990)
return d.name + " - " + d["year" + year]
})
})
};
// ---------------------------------------------------
// We'll be using simpler data as values, not objects.
var myArray = [];
myData.forEach(function(d, i){
// now we add another data object value, a calculated value.
// here we are making strings into numbers using type coercion
d.year1990 = +d.year1990;
d.year2015 = +d.year2015;
// d.difference = d.year2015 - d.year1990;
if (d.name === "Developing regions") {
d.name = "Developing Regions";
}
if (d.name === "Developed regions") {
d.name = "Deveoloped Regions";
}
// Add a new array with the values of each:
myArray.push([d.name, d.year1990, d.year2015]);
});
console.log(myData);
console.log(myArray);
//sort data by difference
myArray.sort(function (a, b) {
return a[3]-b[3];
});
// You could also have made the new array with a map function!
//using colors and fonts from the UNICEF Style Guide
var table = d3.select("#table").append("table");
var header = table.append("thead").append("tr");
header
.selectAll("th")
.data(["Region", "1990", "2015"]) //
.enter()
.append("th")
.text(function(d) { return d; });
var tablebody = table.append("tbody");
rows = tablebody
.selectAll("tr")
.data(myArray)
.enter()
.append("tr");
// We built the rows using the nested array - now each row has its own array.
cells = rows.selectAll("td")
// each row has data associated; we get it and enter it for the cells.
.data(function(d) {
console.log(d);
return d;
})
.enter()
.append("td")
.text(function(d) {
return d;
});
});
</script>
</body>
</html>