-
Notifications
You must be signed in to change notification settings - Fork 4
/
NeffPopPredictions.html
365 lines (306 loc) · 12.2 KB
/
NeffPopPredictions.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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8">
<meta name="Author" content="Leslie Bondaryk" />
<meta name="Owner" content="Pearson" />
<meta name="Copyright" content="Copyright (c) 2013 Pearson. All rights reserved." />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="Carmen Santiago, Demo Book" name="description" />
<title class="setTitle"></title>
<!-- bootstrap_plus.css contains styling for the dropdown menu and other common core styles -->
<link href="css/bootstrap_plus.css" rel="stylesheet" media="screen">
<!-- widgets.css contains styling for the interactive brix -->
<link href="css/widgets.css" rel="stylesheet">
<!-- eCourse-master.css contains styling for all the navigation -->
<link href="css/eCourse-master.css" rel="stylesheet" media="screen">
<!-- content_styles.css contains styling for the narrative layout and responsive design -->
<link href="css/content_styles.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<div class="span12 lc_ec_page">
<section class="lc_ec_fiftyFifty lc_ec_pageInner">
<div class="lc_ec_content">
<h2 class="lc_ec_bHead"><span class='number setId'></span>
<span class="setTitle"></span>
</h2>
<div class="lc_ec_leading">
<p> Consider the following facts: The human population reached 1 billion in the early 1800s, 2 billion by 1925, 3 billion by 1960, 4 billion by 1974, 5 billion by the late 1980s, 6 billion by about 1996, and 7 billion by about 2011. Thinking about this increase in another way, it took the vast majority of human history to reach a population of 1 billion, but only about 15 years to add the most recent billion. The figure highlights this rapid growth.</p>
<p>The astounding growth of the human population over the past few centuries is a consequence of basic reproductive biology. In a nutshell, when a population grows, there will be more people who can have children, and therefore the population will grow even faster. This change is represented as the <a href="#def0" class="term">growth rate</a>, the number of people added over a period of time divided by the size of the total population. The world's population is now increasing at a rate of about 1.2 percent per year; a rate that is equivalent to the annual addition of 1.2 people for every 100 people. This may not sound like a lot, but in a population of 7 billion people, a 1.2 percent growth rate means that about 84 million people will be added in a year. </p>
<p>At this growth rate, the world's population would hit 9 billion around 2033. In the figure, you can see what happens if the growth rate falls or rises just a little, and as you can see, small changes in the growth rate can have big impacts on future population growth.</p>
</div>
<div class="lc_ec_trailing">
<div id="graph0"></div>
<table width="100%">
<tr><td colspan="2">
<span id="growthSlider"></span> </td></tr>
<tr><td class="rightAlign"><span id="popDay"></span></td>
<td class="rightAlign"><span id="pop2010"></span></td></tr>
<tr><td class="rightAlign"><span id="popWeek"></span></td>
<td class="rightAlign"><span id="pop2050"></span></td></tr>
<tr><td class="rightAlign"><span id="popYear"></span></td></tr>
</table>
</div>
</div>
</section>
</div>
</div>
<div class="aside" id='def0'>
<div class="label">Growth rate</div>
<div class="content">The number of people added over a period of time divided by the size of the total population.
</div>
</div>
<script src="js/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui-1.10.2.custom.js"></script>
<script src="js/toc-structure.js"></script>
<script src="js/eCourse-master.js"></script>
<script src="js/d3.v3.min.js"></script>
<script src="js/brixlib-compiled.js"></script>
<!--
<script src="js/widget-base.js"></script>
<script src="js/widget-linegraph.js"></script>
<script src="js/widget-slider.js"></script>
<script src="js/widget-callouts.js"></script>
<script src="js/widget-legend.js"></script>
<script src="js/widget-numeric.js"></script>
<script src="js/eventmanager.js"></script>
!-->
<script>
// local aliases for convenience
var Size = pearson.utils.Size;
var SVGContainer = pearson.brix.SVGContainer;
var Image = pearson.brix.Image;
var CaptionedImage = pearson.brix.CaptionedImage;
var Carousel = pearson.brix.Carousel;
var ImageViewer = pearson.brix.ImageViewer;
var Callouts = pearson.brix.Callouts;
var LineGraph = pearson.brix.LineGraph;
var Slider = pearson.brix.Slider;
var Readout = pearson.brix.Readout;
var Sketch = pearson.brix.Sketch;
var Legend = pearson.brix.Legend;
var EventManager = pearson.utils.EventManager;
var SubmitManager = pearson.brix.SubmitManager;
var MultipleChoiceQuestion = pearson.brix.MultipleChoiceQuestion;
var SelectGroup = pearson.brix.SelectGroup;
var eventManager = new EventManager();
// Create the callout array, which also emits events so you
//can click on the table row to highlight the labels.
/*var rowDefs = new Callouts({
id: "varDefs",
show: "all",
//type: "numbered",
headers: ["where" ],
textBits: [
{cols: ['<span class="math">R</span> is resistance,']},
{cols:[ '<span class="math">ρ</span> is resistivity, ']},
{cols:[ '<span class="math">L</span> is length, and']},
{cols:['<span class="math">A</span> is area.']}
]
},eventManager);
rowDefs.draw(d3.select("#defs"));
*/
var lineData = [
{x: 1900 , y: 1.55 },
{x: 1910 , y: 1.75 },
{x: 1920 , y: 1.86 },
{x: 1930 , y: 2.07 },
{x: 1940 , y: 2.3 },
{x: 1950 , y: 2.529346 },
{x: 1955 , y: 2.763453 },
{x: 1960 , y: 3.023358 },
{x: 1965 , y: 3.33167 },
{x: 1970 , y: 3.685777 },
{x: 1975 , y: 4.061317 },
{x: 1980 , y: 4.437609 },
{x: 1985 , y: 4.846247 },
{x: 1990 , y: 5.290452 },
{x: 1995 , y: 5.713073 },
{x: 2000 , y: 6.115367 },
{x: 2005 , y: 6.512276 },
{x: 2010 , y: 6.908688 }
]; // array of data - could be read from file
var growRt = new Slider ({
id: "growth",
startVal: 1.2,
minVal: 0,
maxVal: 2.5,
stepVal: .1,
unit: "%",
label: "Growth Rate",
format: d3.format('.1f')
}, eventManager);
growRt.draw(d3.select("#growthSlider"));
var N0 = 6.908688;
// Create the population growth in a day
var popDayRead = new Readout({
node: d3.select("#popDay"),
id: 'pDay',
startVal: d3.format(",.0f")(1E9*N0*(Math.exp(growRt.getValue()/36500)-1)),
readOnly: true,
size: 5,
label: "Born in one day"
});
// Create the population growth in a week
var popWkRead = new Readout({
node: d3.select("#popWeek"),
id: 'pWk',
startVal: d3.format(",.0f")(1E9*N0*(Math.exp(growRt.getValue()/5200)-1)),
readOnly: true,
size: 5,
label: "Born in one week"
});
// Create the population growth in a year
var popYearRead = new Readout({
node: d3.select("#popYear"),
id: 'pYr',
startVal: d3.format(",.0f")(1E9*N0*(Math.exp(growRt.getValue()/100)-1)),
readOnly: true,
size: 5,
label: "Born in one year"
});
// Create the population growth in 2010 (historic census data)
var popNow = new Readout({
node: d3.select("#pop2010"),
id: 'pNow',
startVal: d3.format(",.0f")(1E9*N0),
readOnly: true,
size: 5,
label: "2010 Population"
});
// Create the population projected for 2050, 40 years on
var popProj = new Readout({
node: d3.select("#pop2050"),
id: 'pProj',
startVal: d3.format(",.0f")(1E9*N0*(Math.exp(40*growRt.getValue()/100))),
readOnly: true,
size: 5,
label: "2050 Population"
}, eventManager);
projected = [];
for (i=0;i<10;i++){
projected[i] = { x: 2010 + i*5,
y: 6.908688*Math.exp(growRt.getValue()*(.05*i))};
}
nineB = [
{x: 1900, y:9},
{x: 2050, y:9}
];
var xData=[], yData=[];
var Data = [lineData,projected,nineB];
//generate the exp data based on the slider values
function expXYData(inputVals)
{
var pts = inputVals.pts;
var amplitudeX = inputVals.amplitudeX;
var amplitudeY = inputVals.amplitudeY;
var data = [];
for (i = 0; i < pts; i++)
{
data[i] = { x: 2010 + i*5,
y: 6.908688*Math.exp(growRt.getValue()*(.5*i))};
}
return data;
}
// configure and draw the SVG container and the graph of the population data
var cont1 = new SVGContainer({
node: d3.select("#graph0"),
maxWid: 500,
maxHt: 320
});
var lines = new LineGraph({
id: "lg0",
Data: Data,
type: "lines",
xAxisFormat: { type: "linear",
ticks: [1900,1950,1990,2010,2030,2050],
orientation: "bottom",
label: "Year" },
yAxisFormat: { type: "linear",
orientation: "left",
label: "Human Population (Billions)",
ticks: 7,
},
},eventManager);
cont1.append(lines, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
// configure and append the legend to the graph
var legLines = new Legend({
xPos: "right", yPos: "bottom",
labels: [{ content: "historical data", },
{ content: "predicted", },
{ content: "threshold" ,}],
type: "line"
},eventManager);
lines.append(legLines);
// Handle changes of the growth rate slider (one subscription per
// event we listen to)
eventManager.subscribe(growRt.changedValueEventId,
handleChangedValue);
eventManager.subscribe(legLines.selectedEventId,
handleHighlight);
eventManager.subscribe(lines.selectedEventId,
handleHighlight);
/* **************************************************************************
* handleInputValueChanged *//**
*
* handleInputValueChanged is called from the event handler for one of
* the input widgets when the user changes its value. It updates the
* given matching input widget's value to match the new value and then
* updates the bar chart.
*
* @param {NumericInput} otherInputWidget -This is the other input widget
* whose value needs to be updated
* to match the user changed widget.
* @param {number} newValue - The value of the widget that was changed.
*
****************************************************************************/
function handleChangedValue(newValue)
{
//get the values of the growth rate
newRate = growRt.getValue();
//use that to calculate the new populations
popDayRead.setValue(d3.format(",.0f")
(1E9*N0*(Math.exp(newRate/36500)-1)));
popWkRead.setValue(d3.format(",.0f")
(1E9*N0*(Math.exp(newRate/5200)-1)));
// factor of 100 to convert to percent decimal value
popYearRead.setValue(d3.format(",.0f")
(1E9*N0*(Math.exp(newRate/100)-1)));
// factor of 100 to convert to percent decimal value
popProj.setValue(d3.format(",.0f")
(1E9*N0*(Math.exp(40*newRate/100))));
//recalculate the data
for (i=0;i<10;i++){
projected[i] = { x: 2010 + i*5,
y: 6.908688*Math.exp(growRt.getValue()*(.05*i))};
}
// update the linegraph w/ the new data
lines.data_[1] = projected;
//redraw the dots
lines.redraw();
}
/************************************************************************
* handleHighlight *//**
*
* handleInputValueChanged is called from the event handler for one of
* the input widgets when the user changes its value. It updates the
* given matching input widget's value to match the new value and then
* updates the bar chart.
*
* @param eventDetails These are the keyed values returned by
* the event, in this case, a selection
* (click).
*************************************************************************/
function handleHighlight(eventDetails)
{
//Handler needs to get written into each page,
//each widget will have it's own way of responding
lines.lite(eventDetails.selectKey);
legLines.lite(eventDetails.selectKey);
}
</script>
</body>
</html>