-
Notifications
You must be signed in to change notification settings - Fork 4
/
NeffAgeStructureSims.html
288 lines (245 loc) · 7.53 KB
/
NeffAgeStructureSims.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
<?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="Jason Neff" />
<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="Our Changing Planet" 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_minorMajor lc_ec_pageInner">
<div class="lc_ec_content">
<h2 class="lc_ec_bHead"><span class='number setId'>Chapter 12</span>
<span class="setTitle">Population Simulation</span>
</h2>
<div class="lc_ec_leading">
<p> This simulation allows you to change the initial population distribution, type of mortality structure, the total fertility rate and the age of first childbirth for a fictitious society. </p>
</div>
<div class="lc_ec_trailing">
<table width="100%" style="margin: 10; padding: 5" border="1">
<tr><td><span id="dropdown1">Mortality Type </span></td>
<td><span id="dropdown0">Total Fertility Rate </span></td>
</tr>
<tr>
<td>Age of first birth <span id="slider1"></span></td>
<td>Starting Population: 10,000 <div id="readout0"><span id="readout1"></span></div>
</td>
</tr>
<tr><td><span id="slider2"></span></td></tr>
</table>
<div id="graph0"></div>
</div>
</div>
</section>
</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="../closure/closure-library/closure/goog/base.js"></script>
<script src="js/brixlib-deps.js"></script>
<script>
goog.require('pearson.brix.BricLayer');
</script>
-->
<script>
// local aliases for convenience
pearson.utils.logToConsole(true, 'FINER');
var SVGContainer = pearson.brix.SVGContainer;
var LineGraph = pearson.brix.LineGraph;
var BarChart = pearson.brix.BarChart;
var Slider = pearson.brix.Slider;
var Readout = pearson.brix.Readout;
var Legend = pearson.brix.Legend;
var EventManager = pearson.utils.EventManager;
var SelectGroup = pearson.brix.SelectGroup;
var eventManager = new EventManager();
var years = 100;
var maxAge = 100;
var initialPop = 10000;
// Select initial population distribution type
/*var popDistribution = new SelectGroup(
{
choices: [
{
content: "Type I (triangle)",
},
{
content: "Type II (uniform)",
},
{
content: "Type III (pyramid)",
},
]
}, eventManager);
popDistribution.draw(d3.select("#dropdown0"));
*/
// Select mortality type
var profiles = new SelectGroup(
{
id: "mort-selgrp",
choices: [
{
content: "Highly developed nations",
},
{
content: "Developing nations",
},
{
content: "Least developed nations",
},
]
}, eventManager);
profiles.draw(d3.select("#dropdown1"));
// slider for looking at different years in the population evolution
var fertileDrop = new SelectGroup(
{
id: "fert-selgrp",
choices: [
{
content: "T<sub>f</sub> = 0 children/female",
},
{
content: "T<sub>f</sub> = 1 child/female",
},
{
content: "T<sub>f</sub> = 2 children/female",
},
{
content: "T<sub>f</sub> = 3 children/female",
},
{
content: "T<sub>f</sub> = 4 child/female",
},
{
content: "T<sub>f</sub> = 5 children/female",
}
]
}, eventManager);
fertileDrop.draw(d3.select("#dropdown0"));
// slider for looking at different age of first childbirth
var ageFirstBirthDrop = new SelectGroup(
{
id: "ageBrth-selgrp",
choices: [
{
content: "A<sub>c</sub> = 15",
},
{
content: "A<sub>c</sub> = 20",
},
{
content: "A<sub>c</sub> = 25",
},
{
content: "A<sub>c</sub> = 30",
},
{
content: "A<sub>c</sub> = 35",
},
{
content: "A<sub>c</sub> = 40",
}
]
}, eventManager);
ageFirstBirthDrop.draw(d3.select("#slider1"));
// slider for looking at different years in the population evolution
var yearSlide = new Slider ({
startVal: 0,
minVal: 0,
maxVal: years,
stepVal: 1,
width: '100%',
unit: "years",
label: "Years elapsed",
format: d3.format('.1f')
}, eventManager);
yearSlide.draw(d3.select("#slider2"));
var cont1 = new SVGContainer({
node: d3.select("#graph0"),
maxWid: 577,
maxHt: 450
});
var barsWomen = new BarChart({
id: "lg0",
Data: [[]],
type: "lines",
xAxisFormat: { type: "linear",
ticks: [0, initialPop/40, initialPop/20],
orientation: "bottom",
label: "Female population" },
yAxisFormat: { type: "ordinal",
orientation: "left",
label: "Age",
ticks: 10
},
},eventManager);
var barsMen = new BarChart ({
Data: [[]],
xAxisFormat: {
type: "linear",
mode: "reverse",
ticks: [0, initialPop/40, initialPop/20],
orientation: "bottom",
label: "Male population"},
yAxisFormat: { type: "ordinal",
orientation: "right",
ticks: 10
},
});
var endPop = new Readout({
node: d3.select("#readout0"),
//startVal: 100000,
readOnly: true,
size: 5,
label: ""
});
var yearPop = new Readout({
node: d3.select("#readout1"),
//startVal: 100000,
readOnly: true,
size: 5,
unit: "years: ",
label: "Total population after "
});
var popConfig =
{
yearSlider: yearSlide,
yearTopic: yearSlide.changedValueEventId,
//popDistributionTopic: popDistribution.selectedEventId,
mortTopic: profiles.selectedEventId,
fertilityTopic: fertileDrop.selectedEventId,
ageFirstBirthTopic: ageFirstBirthDrop.selectedEventId,
targetBricLeft: barsWomen,
targetBricRight: barsMen,
targetPopReadout: endPop,
targetYearReadout: yearPop
};
fertileDrop.selectChoice(2);
var popMortar = new pearson.brix.mortar.AgeStructure(popConfig, eventManager);
//barsWomen.data_ = [[], popMortar.populationWomen_[0]];
//barsMen.data_ = [popMortar.populationMen_[0]];
//endPop.setValue(popMortar.totalPopulation[0]);
cont1.append(barsWomen, {topPercentOffset: 0, leftPercentOffset: .45, heightPercent: 1, widthPercent: 0.55});
cont1.append(barsMen, {topPercentOffset: 0, leftPercentOffset: 0.05, heightPercent: 1, widthPercent: 0.45});
</script>
</body>
</html>