├── README.md ├── css └── style.css ├── index.html └── js ├── asian_countries.json ├── barChart.js ├── countries.js ├── dotHistogram.js ├── finalText.js ├── helperFunctions.js ├── introDotHistogram.js ├── introSlope.js ├── introText.js ├── introUrbanScatter.js ├── introduceCities.js ├── setStepper.js ├── slopeGraph.js ├── startBar.js ├── totalAreaMap.js ├── underscore.js ├── urbanPopDot.js └── urban_areas.js /README.md: -------------------------------------------------------------------------------- 1 | # urbanization 2 | A storytelling/narrative approach to explaining the urbanization in East Asia between 2000 and 2010 3 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | /*overflow: hidden;*/ 3 | margin: 0; 4 | font-size: 10px; 5 | font-family: 'Open Sans', sans-serif; 6 | font-weight: 300; 7 | color: #292929; 8 | } 9 | 10 | a { 11 | text-decoration: none; 12 | color: #6B6B6B; 13 | } 14 | 15 | #credits { 16 | position: absolute; 17 | left: 760px; 18 | top: 700px; 19 | z-index: 100; 20 | } 21 | 22 | .creditText { 23 | text-align: right; 24 | font-size: 9px; 25 | font-weight: 300; 26 | color: #6B6B6B; 27 | } 28 | 29 | #titleAll { 30 | font-family: Oswald; 31 | font-size: 24px; 32 | font-weight: 300; 33 | padding: 10px 0px 0px 20px; 34 | /*text-transform: uppercase;*/ 35 | } 36 | 37 | #rule{ 38 | height:1px; 39 | background:#ddd; 40 | width:700px; 41 | } 42 | 43 | #callOut { 44 | position: absolute; 45 | left: 30px; 46 | top: 570px; 47 | width: 310px; 48 | height: 100px; 49 | font-size: 11px; 50 | visibility: hidden; 51 | } 52 | 53 | .callOutTitle { 54 | font-family: Oswald; 55 | font-size: 18px; 56 | font-weight: 300; 57 | padding-bottom: 2px; 58 | } 59 | 60 | #callOutrule{ 61 | height:1px; 62 | background: #B3B3B3; 63 | width:225px; 64 | margin-bottom: 6px; 65 | } 66 | 67 | table.fixed { table-layout:fixed; width:310px;} 68 | table.fixed td { overflow: hidden; } 69 | 70 | #callOutCountryWrapper { 71 | position: absolute; 72 | left: 200px; 73 | top: 250px; 74 | width: 300px; 75 | height: 50px; 76 | visibility: hidden; 77 | } 78 | 79 | #explanation { 80 | font-size: 18px; 81 | top: 200px; 82 | left: 50px; 83 | width: 550px; 84 | line-height: 150%; 85 | } 86 | 87 | #explanationIntro { 88 | font-size: 12px; 89 | top: 475px; 90 | left: 50px; 91 | width: 550px; 92 | line-height: 180%; 93 | color: #5E5E5E; 94 | } 95 | 96 | .expl-text { 97 | position: absolute; 98 | text-align: center; 99 | } 100 | 101 | #section { 102 | position: absolute; 103 | top: 60px; 104 | left: 650px; 105 | width: 320px; 106 | visiblity: hidden; 107 | } 108 | 109 | #sectionTitle { 110 | font-family: Oswald; 111 | font-size: 18px; 112 | font-weight: 300; 113 | padding-bottom: 7px; 114 | } 115 | 116 | #sectionText { 117 | color: #6B6B6B; 118 | text-align: justify; 119 | line-height: 150%; 120 | } 121 | 122 | #clickerWrapper { 123 | z-index: 10; 124 | display: block; 125 | position: absolute; 126 | width: 1000px; 127 | top: 680px; 128 | visibility: auto; 129 | } 130 | 131 | #progressButtonWrapper{ 132 | text-align: center; 133 | position: relative; 134 | width: 400px; 135 | height: 30px; 136 | margin: 0 auto; 137 | } 138 | 139 | #progress { 140 | z-index: 1; 141 | display: block; 142 | position: relative; 143 | width: 40%; 144 | height: 6px; 145 | margin: 0px auto; 146 | padding-bottom: 30px; 147 | visibility: hidden; 148 | } 149 | 150 | .progressButton { 151 | display: block; 152 | font-family: Oswald; 153 | font-size: 20px; 154 | font-weight: 300; 155 | position: relative; 156 | /*width: 80px;*/ 157 | text-align: center; 158 | width: 20%; 159 | margin: 0 auto; 160 | border: 1px solid; 161 | cursor: pointer; 162 | display:inline-block; 163 | } 164 | 165 | .activeButton { 166 | color: #363636; 167 | border-color: #363636; 168 | cursor: pointer; 169 | } 170 | 171 | .inactiveButton { 172 | color: #D3D3D3; 173 | border-color: #D3D3D3; 174 | cursor: default; 175 | pointer-events: none; 176 | } 177 | 178 | .space{ 179 | position: relative; 180 | width: 2%; 181 | height: 10px; 182 | display:inline-block; 183 | cursor: default; 184 | } 185 | 186 | .circleBase { 187 | position: relative; 188 | border-radius: 50%; 189 | behavior: url(PIE.htc); /* remove if you don't care about IE8 */ 190 | width: 10px; 191 | height: 10px; 192 | border: 1px solid #D3D3D3; 193 | top: -5px; 194 | display:inline-block; 195 | background: white; 196 | } 197 | 198 | #viewOuterWrapper { 199 | top: 0; 200 | display: block; 201 | position: absolute; 202 | width: 300px; 203 | top: 742px; 204 | left: 25px; 205 | } 206 | 207 | .view { 208 | font-size: 12px; 209 | width: 12%; 210 | } 211 | 212 | .activeButtonView { 213 | color: #5E5E5E; 214 | border-color: #7F7F7F; 215 | cursor: pointer; 216 | } 217 | 218 | .clickable { 219 | cursor: pointer; 220 | } 221 | 222 | .stepLine { 223 | stroke-width: 1; 224 | stroke: #AAAAAA; 225 | } 226 | 227 | .stepText { 228 | color: #AAAAAA; 229 | } 230 | 231 | .stepRect { 232 | fill: white; 233 | opacity: 0; 234 | } 235 | 236 | .geo-path { 237 | stroke: white; 238 | stroke-width: 1.5px; 239 | stroke-opacity: 1; 240 | fill: #E5D9C9; 241 | fill-opacity: 1; 242 | } 243 | 244 | .city_2000 { 245 | fill: #858483; 246 | color: #858483; 247 | opacity: 1; 248 | } 249 | 250 | .city_2010 { 251 | fill: #DA6761; 252 | color: #DA6761; 253 | opacity: 1; 254 | } 255 | 256 | .titleTop { 257 | font-family: Oswald; 258 | font-size: 16px; 259 | font-weight: 300; 260 | fill: #525252; 261 | } 262 | 263 | .title { 264 | font-size: 12px; 265 | fill: #A6A6A6; 266 | } 267 | 268 | .barTitle { 269 | font-size: 14px; 270 | } 271 | 272 | .subTitle { 273 | text-anchor: middle; 274 | font-size: 10px; 275 | fill: #A3A3A3; 276 | font-weight: 300; 277 | } 278 | 279 | text { 280 | cursor: default; 281 | fill: #525252; 282 | } 283 | 284 | .btn-group { 285 | position: relative; 286 | top: 400px; 287 | left: 40px; 288 | visibility: hidden; 289 | } 290 | 291 | .btn { 292 | font-size: 10px; 293 | border-radius:0; 294 | padding: 3px 7px; 295 | line-height: 1.5; 296 | font-family: 'Open Sans', sans-serif; 297 | font-weight: 300; 298 | } 299 | 300 | .axis path, 301 | .axis line { 302 | fill: none; 303 | stroke: #8C8C8C; 304 | shape-rendering: crispEdges; 305 | } 306 | .axis text { 307 | font-size: 8px; 308 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Urbanization in East Asia 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | Urbanization in East Asia between 2000 and 2010 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 |
Urban Pop.
[million]
Urban Land
[sq. km]
Urban Pop. Density
[people/sq. km]
2000000
2010 (rank)000
Growth %0%0%0%
88 | 89 |
90 | 91 | 92 |
93 |
Tokyo
94 |
95 | 96 | 97 |
98 |
99 |
100 |
Back
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
Continue
113 |
114 |
115 | 116 | 117 | 130 | 131 |
132 |
Visuals | Nadieh Bremer | VisualCinnamon.com
133 |
Text | Nadieh Bremer & Marlieke Ranzijn
134 |
Inspiration | World Bank report
135 |
Data | World Bank open & PUMA datasets
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 | 405 | 406 | 407 | 408 | 409 | -------------------------------------------------------------------------------- /js/asian_countries.json: -------------------------------------------------------------------------------- 1 | {"type":"FeatureCollection","features":[ 2 | {"type":"Feature","properties":{"name":"Brunei"},"geometry":{"type":"Polygon","coordinates":[[[114.204017,4.525874],[114.599961,4.900011],[115.45071,5.44773],[115.4057,4.955228],[115.347461,4.316636],[114.869557,4.348314],[114.659596,4.007637],[114.204017,4.525874]]]},"id":"BRN"}, 3 | {"type":"Feature","properties":{"name":"China"},"geometry":{"type":"MultiPolygon","coordinates":[[[[110.339188,18.678395],[109.47521,18.197701],[108.655208,18.507682],[108.626217,19.367888],[109.119056,19.821039],[110.211599,20.101254],[110.786551,20.077534],[111.010051,19.69593],[110.570647,19.255879],[110.339188,18.678395]]],[[[127.657407,49.76027],[129.397818,49.4406],[130.582293,48.729687],[130.987282,47.790132],[132.506672,47.78897],[133.373596,48.183442],[135.026311,48.47823],[134.500814,47.57844],[134.112362,47.212467],[133.769644,46.116927],[133.097127,45.144066],[131.883454,45.321162],[131.025212,44.967953],[131.288555,44.11152],[131.144688,42.92999],[130.633866,42.903015],[130.640016,42.395009],[129.994267,42.985387],[129.596669,42.424982],[128.052215,41.994285],[128.208433,41.466772],[127.343783,41.503152],[126.869083,41.816569],[126.182045,41.107336],[125.079942,40.569824],[124.265625,39.928493],[122.86757,39.637788],[122.131388,39.170452],[121.054554,38.897471],[121.585995,39.360854],[121.376757,39.750261],[122.168595,40.422443],[121.640359,40.94639],[120.768629,40.593388],[119.639602,39.898056],[119.023464,39.252333],[118.042749,39.204274],[117.532702,38.737636],[118.059699,38.061476],[118.87815,37.897325],[118.911636,37.448464],[119.702802,37.156389],[120.823457,37.870428],[121.711259,37.481123],[122.357937,37.454484],[122.519995,36.930614],[121.104164,36.651329],[120.637009,36.11144],[119.664562,35.609791],[119.151208,34.909859],[120.227525,34.360332],[120.620369,33.376723],[121.229014,32.460319],[121.908146,31.692174],[121.891919,30.949352],[121.264257,30.676267],[121.503519,30.142915],[122.092114,29.83252],[121.938428,29.018022],[121.684439,28.225513],[121.125661,28.135673],[120.395473,27.053207],[119.585497,25.740781],[118.656871,24.547391],[117.281606,23.624501],[115.890735,22.782873],[114.763827,22.668074],[114.152547,22.22376],[113.80678,22.54834],[113.241078,22.051367],[111.843592,21.550494],[110.785466,21.397144],[110.444039,20.341033],[109.889861,20.282457],[109.627655,21.008227],[109.864488,21.395051],[108.522813,21.715212],[108.05018,21.55238],[107.04342,21.811899],[106.567273,22.218205],[106.725403,22.794268],[105.811247,22.976892],[105.329209,23.352063],[104.476858,22.81915],[103.504515,22.703757],[102.706992,22.708795],[102.170436,22.464753],[101.652018,22.318199],[101.80312,21.174367],[101.270026,21.201652],[101.180005,21.436573],[101.150033,21.849984],[100.416538,21.558839],[99.983489,21.742937],[99.240899,22.118314],[99.531992,22.949039],[98.898749,23.142722],[98.660262,24.063286],[97.60472,23.897405],[97.724609,25.083637],[98.671838,25.918703],[98.712094,26.743536],[98.68269,27.508812],[98.246231,27.747221],[97.911988,28.335945],[97.327114,28.261583],[96.248833,28.411031],[96.586591,28.83098],[96.117679,29.452802],[95.404802,29.031717],[94.56599,29.277438],[93.413348,28.640629],[92.503119,27.896876],[91.696657,27.771742],[91.258854,28.040614],[90.730514,28.064954],[90.015829,28.296439],[89.47581,28.042759],[88.814248,27.299316],[88.730326,28.086865],[88.120441,27.876542],[86.954517,27.974262],[85.82332,28.203576],[85.011638,28.642774],[84.23458,28.839894],[83.898993,29.320226],[83.337115,29.463732],[82.327513,30.115268],[81.525804,30.422717],[81.111256,30.183481],[79.721367,30.882715],[78.738894,31.515906],[78.458446,32.618164],[79.176129,32.48378],[79.208892,32.994395],[78.811086,33.506198],[78.912269,34.321936],[77.837451,35.49401],[76.192848,35.898403],[75.896897,36.666806],[75.158028,37.133031],[74.980002,37.41999],[74.829986,37.990007],[74.864816,38.378846],[74.257514,38.606507],[73.928852,38.505815],[73.675379,39.431237],[73.960013,39.660008],[73.822244,39.893973],[74.776862,40.366425],[75.467828,40.562072],[76.526368,40.427946],[76.904484,41.066486],[78.187197,41.185316],[78.543661,41.582243],[80.11943,42.123941],[80.25999,42.349999],[80.18015,42.920068],[80.866206,43.180362],[79.966106,44.917517],[81.947071,45.317027],[82.458926,45.53965],[83.180484,47.330031],[85.16429,47.000956],[85.720484,47.452969],[85.768233,48.455751],[86.598776,48.549182],[87.35997,49.214981],[87.751264,49.297198],[88.013832,48.599463],[88.854298,48.069082],[90.280826,47.693549],[90.970809,46.888146],[90.585768,45.719716],[90.94554,45.286073],[92.133891,45.115076],[93.480734,44.975472],[94.688929,44.352332],[95.306875,44.241331],[95.762455,43.319449],[96.349396,42.725635],[97.451757,42.74889],[99.515817,42.524691],[100.845866,42.663804],[101.83304,42.514873],[103.312278,41.907468],[104.522282,41.908347],[104.964994,41.59741],[106.129316,42.134328],[107.744773,42.481516],[109.243596,42.519446],[110.412103,42.871234],[111.129682,43.406834],[111.829588,43.743118],[111.667737,44.073176],[111.348377,44.457442],[111.873306,45.102079],[112.436062,45.011646],[113.463907,44.808893],[114.460332,45.339817],[115.985096,45.727235],[116.717868,46.388202],[117.421701,46.672733],[118.874326,46.805412],[119.66327,46.69268],[119.772824,47.048059],[118.866574,47.74706],[118.064143,48.06673],[117.295507,47.697709],[116.308953,47.85341],[115.742837,47.726545],[115.485282,48.135383],[116.191802,49.134598],[116.678801,49.888531],[117.879244,49.510983],[119.288461,50.142883],[119.279366,50.582908],[120.18205,51.643566],[120.738191,51.964115],[120.725789,52.516226],[120.177089,52.753886],[121.003085,53.251401],[122.245748,53.431726],[123.571507,53.458804],[125.068211,53.161045],[125.946349,52.792799],[126.564399,51.784255],[126.939157,51.353894],[127.287456,50.739797],[127.657407,49.76027]]]]},"id":"CHN"}, 4 | {"type":"Feature","properties":{"name":"Cambodia"},"geometry":{"type":"Polygon","coordinates":[[[103.49728,10.632555],[103.09069,11.153661],[102.584932,12.186595],[102.348099,13.394247],[102.988422,14.225721],[104.281418,14.416743],[105.218777,14.273212],[106.043946,13.881091],[106.496373,14.570584],[107.382727,14.202441],[107.614548,13.535531],[107.491403,12.337206],[105.810524,11.567615],[106.24967,10.961812],[105.199915,10.88931],[104.334335,10.486544],[103.49728,10.632555]]]},"id":"KHM"}, 5 | {"type":"Feature","properties":{"name":"North Korea"},"geometry":{"type":"Polygon","coordinates":[[[130.640016,42.395009],[130.780007,42.220007],[130.400031,42.280004],[129.965949,41.941368],[129.667362,41.601104],[129.705189,40.882828],[129.188115,40.661808],[129.0104,40.485436],[128.633368,40.189847],[127.967414,40.025413],[127.533436,39.75685],[127.50212,39.323931],[127.385434,39.213472],[127.783343,39.050898],[128.349716,38.612243],[128.205746,38.370397],[127.780035,38.304536],[127.073309,38.256115],[126.68372,37.804773],[126.237339,37.840378],[126.174759,37.749686],[125.689104,37.94001],[125.568439,37.752089],[125.27533,37.669071],[125.240087,37.857224],[124.981033,37.948821],[124.712161,38.108346],[124.985994,38.548474],[125.221949,38.665857],[125.132859,38.848559],[125.38659,39.387958],[125.321116,39.551385],[124.737482,39.660344],[124.265625,39.928493],[125.079942,40.569824],[126.182045,41.107336],[126.869083,41.816569],[127.343783,41.503152],[128.208433,41.466772],[128.052215,41.994285],[129.596669,42.424982],[129.994267,42.985387],[130.640016,42.395009]]]},"id":"PRK"}, 6 | {"type":"Feature","properties":{"name":"Indonesia"},"geometry":{"type":"MultiPolygon","coordinates":[[[[120.715609,-10.239581],[120.295014,-10.25865],[118.967808,-9.557969],[119.90031,-9.36134],[120.425756,-9.665921],[120.775502,-9.969675],[120.715609,-10.239581]]],[[[124.43595,-10.140001],[123.579982,-10.359987],[123.459989,-10.239995],[123.550009,-9.900016],[123.980009,-9.290027],[124.968682,-8.89279],[125.07002,-9.089987],[125.08852,-9.393173],[124.43595,-10.140001]]],[[[117.900018,-8.095681],[118.260616,-8.362383],[118.87846,-8.280683],[119.126507,-8.705825],[117.970402,-8.906639],[117.277731,-9.040895],[116.740141,-9.032937],[117.083737,-8.457158],[117.632024,-8.449303],[117.900018,-8.095681]]],[[[122.903537,-8.094234],[122.756983,-8.649808],[121.254491,-8.933666],[119.924391,-8.810418],[119.920929,-8.444859],[120.715092,-8.236965],[121.341669,-8.53674],[122.007365,-8.46062],[122.903537,-8.094234]]],[[[108.623479,-6.777674],[110.539227,-6.877358],[110.759576,-6.465186],[112.614811,-6.946036],[112.978768,-7.594213],[114.478935,-7.776528],[115.705527,-8.370807],[114.564511,-8.751817],[113.464734,-8.348947],[112.559672,-8.376181],[111.522061,-8.302129],[110.58615,-8.122605],[109.427667,-7.740664],[108.693655,-7.6416],[108.277763,-7.766657],[106.454102,-7.3549],[106.280624,-6.9249],[105.365486,-6.851416],[106.051646,-5.895919],[107.265009,-5.954985],[108.072091,-6.345762],[108.486846,-6.421985],[108.623479,-6.777674]]],[[[134.724624,-6.214401],[134.210134,-6.895238],[134.112776,-6.142467],[134.290336,-5.783058],[134.499625,-5.445042],[134.727002,-5.737582],[134.724624,-6.214401]]],[[[127.249215,-3.459065],[126.874923,-3.790983],[126.183802,-3.607376],[125.989034,-3.177273],[127.000651,-3.129318],[127.249215,-3.459065]]],[[[130.471344,-3.093764],[130.834836,-3.858472],[129.990547,-3.446301],[129.155249,-3.362637],[128.590684,-3.428679],[127.898891,-3.393436],[128.135879,-2.84365],[129.370998,-2.802154],[130.471344,-3.093764]]],[[[134.143368,-1.151867],[134.422627,-2.769185],[135.457603,-3.367753],[136.293314,-2.307042],[137.440738,-1.703513],[138.329727,-1.702686],[139.184921,-2.051296],[139.926684,-2.409052],[141.00021,-2.600151],[141.017057,-5.859022],[141.033852,-9.117893],[140.143415,-8.297168],[139.127767,-8.096043],[138.881477,-8.380935],[137.614474,-8.411683],[138.039099,-7.597882],[138.668621,-7.320225],[138.407914,-6.232849],[137.92784,-5.393366],[135.98925,-4.546544],[135.164598,-4.462931],[133.66288,-3.538853],[133.367705,-4.024819],[132.983956,-4.112979],[132.756941,-3.746283],[132.753789,-3.311787],[131.989804,-2.820551],[133.066845,-2.460418],[133.780031,-2.479848],[133.696212,-2.214542],[132.232373,-2.212526],[131.836222,-1.617162],[130.94284,-1.432522],[130.519558,-0.93772],[131.867538,-0.695461],[132.380116,-0.369538],[133.985548,-0.78021],[134.143368,-1.151867]]],[[[125.240501,1.419836],[124.437035,0.427881],[123.685505,0.235593],[122.723083,0.431137],[121.056725,0.381217],[120.183083,0.237247],[120.04087,-0.519658],[120.935905,-1.408906],[121.475821,-0.955962],[123.340565,-0.615673],[123.258399,-1.076213],[122.822715,-0.930951],[122.38853,-1.516858],[121.508274,-1.904483],[122.454572,-3.186058],[122.271896,-3.5295],[123.170963,-4.683693],[123.162333,-5.340604],[122.628515,-5.634591],[122.236394,-5.282933],[122.719569,-4.464172],[121.738234,-4.851331],[121.489463,-4.574553],[121.619171,-4.188478],[120.898182,-3.602105],[120.972389,-2.627643],[120.305453,-2.931604],[120.390047,-4.097579],[120.430717,-5.528241],[119.796543,-5.6734],[119.366906,-5.379878],[119.653606,-4.459417],[119.498835,-3.494412],[119.078344,-3.487022],[118.767769,-2.801999],[119.180974,-2.147104],[119.323394,-1.353147],[119.825999,0.154254],[120.035702,0.566477],[120.885779,1.309223],[121.666817,1.013944],[122.927567,0.875192],[124.077522,0.917102],[125.065989,1.643259],[125.240501,1.419836]]],[[[128.688249,1.132386],[128.635952,0.258486],[128.12017,0.356413],[127.968034,-0.252077],[128.379999,-0.780004],[128.100016,-0.899996],[127.696475,-0.266598],[127.39949,1.011722],[127.600512,1.810691],[127.932378,2.174596],[128.004156,1.628531],[128.594559,1.540811],[128.688249,1.132386]]],[[[117.875627,1.827641],[118.996747,0.902219],[117.811858,0.784242],[117.478339,0.102475],[117.521644,-0.803723],[116.560048,-1.487661],[116.533797,-2.483517],[116.148084,-4.012726],[116.000858,-3.657037],[114.864803,-4.106984],[114.468652,-3.495704],[113.755672,-3.43917],[113.256994,-3.118776],[112.068126,-3.478392],[111.703291,-2.994442],[111.04824,-3.049426],[110.223846,-2.934032],[110.070936,-1.592874],[109.571948,-1.314907],[109.091874,-0.459507],[108.952658,0.415375],[109.069136,1.341934],[109.66326,2.006467],[109.830227,1.338136],[110.514061,0.773131],[111.159138,0.976478],[111.797548,0.904441],[112.380252,1.410121],[112.859809,1.49779],[113.80585,1.217549],[114.621355,1.430688],[115.134037,2.821482],[115.519078,3.169238],[115.865517,4.306559],[117.015214,4.306094],[117.882035,4.137551],[117.313232,3.234428],[118.04833,2.28769],[117.875627,1.827641]]],[[[105.817655,-5.852356],[104.710384,-5.873285],[103.868213,-5.037315],[102.584261,-4.220259],[102.156173,-3.614146],[101.399113,-2.799777],[100.902503,-2.050262],[100.141981,-0.650348],[99.26374,0.183142],[98.970011,1.042882],[98.601351,1.823507],[97.699598,2.453184],[97.176942,3.308791],[96.424017,3.86886],[95.380876,4.970782],[95.293026,5.479821],[95.936863,5.439513],[97.484882,5.246321],[98.369169,4.26837],[99.142559,3.59035],[99.693998,3.174329],[100.641434,2.099381],[101.658012,2.083697],[102.498271,1.3987],[103.07684,0.561361],[103.838396,0.104542],[103.437645,-0.711946],[104.010789,-1.059212],[104.369991,-1.084843],[104.53949,-1.782372],[104.887893,-2.340425],[105.622111,-2.428844],[106.108593,-3.061777],[105.857446,-4.305525],[105.817655,-5.852356]]]]},"id":"IDN"}, 7 | {"type":"Feature","properties":{"name":"Japan"},"geometry":{"type":"MultiPolygon","coordinates":[[[[134.638428,34.149234],[134.766379,33.806335],[134.203416,33.201178],[133.79295,33.521985],[133.280268,33.28957],[133.014858,32.704567],[132.363115,32.989382],[132.371176,33.463642],[132.924373,34.060299],[133.492968,33.944621],[133.904106,34.364931],[134.638428,34.149234]]],[[[140.976388,37.142074],[140.59977,36.343983],[140.774074,35.842877],[140.253279,35.138114],[138.975528,34.6676],[137.217599,34.606286],[135.792983,33.464805],[135.120983,33.849071],[135.079435,34.596545],[133.340316,34.375938],[132.156771,33.904933],[130.986145,33.885761],[132.000036,33.149992],[131.33279,31.450355],[130.686318,31.029579],[130.20242,31.418238],[130.447676,32.319475],[129.814692,32.61031],[129.408463,33.296056],[130.353935,33.604151],[130.878451,34.232743],[131.884229,34.749714],[132.617673,35.433393],[134.608301,35.731618],[135.677538,35.527134],[136.723831,37.304984],[137.390612,36.827391],[138.857602,37.827485],[139.426405,38.215962],[140.05479,39.438807],[139.883379,40.563312],[140.305783,41.195005],[141.368973,41.37856],[141.914263,39.991616],[141.884601,39.180865],[140.959489,38.174001],[140.976388,37.142074]]],[[[143.910162,44.1741],[144.613427,43.960883],[145.320825,44.384733],[145.543137,43.262088],[144.059662,42.988358],[143.18385,41.995215],[141.611491,42.678791],[141.067286,41.584594],[139.955106,41.569556],[139.817544,42.563759],[140.312087,43.333273],[141.380549,43.388825],[141.671952,44.772125],[141.967645,45.551483],[143.14287,44.510358],[143.910162,44.1741]]]]},"id":"JPN"}, 8 | {"type":"Feature","properties":{"name":"Laos"},"geometry":{"type":"Polygon","coordinates":[[[105.218777,14.273212],[105.544338,14.723934],[105.589039,15.570316],[104.779321,16.441865],[104.716947,17.428859],[103.956477,18.240954],[103.200192,18.309632],[102.998706,17.961695],[102.413005,17.932782],[102.113592,18.109102],[101.059548,17.512497],[101.035931,18.408928],[101.282015,19.462585],[100.606294,19.508344],[100.548881,20.109238],[100.115988,20.41785],[100.329101,20.786122],[101.180005,21.436573],[101.270026,21.201652],[101.80312,21.174367],[101.652018,22.318199],[102.170436,22.464753],[102.754896,21.675137],[103.203861,20.766562],[104.435,20.758733],[104.822574,19.886642],[104.183388,19.624668],[103.896532,19.265181],[105.094598,18.666975],[105.925762,17.485315],[106.556008,16.604284],[107.312706,15.908538],[107.564525,15.202173],[107.382727,14.202441],[106.496373,14.570584],[106.043946,13.881091],[105.218777,14.273212]]]},"id":"LAO"}, 9 | {"type":"Feature","properties":{"name":"Malaysia"},"geometry":{"type":"MultiPolygon","coordinates":[[[[101.075516,6.204867],[101.154219,5.691384],[101.814282,5.810808],[102.141187,6.221636],[102.371147,6.128205],[102.961705,5.524495],[103.381215,4.855001],[103.438575,4.181606],[103.332122,3.726698],[103.429429,3.382869],[103.502448,2.791019],[103.854674,2.515454],[104.247932,1.631141],[104.228811,1.293048],[103.519707,1.226334],[102.573615,1.967115],[101.390638,2.760814],[101.27354,3.270292],[100.695435,3.93914],[100.557408,4.76728],[100.196706,5.312493],[100.30626,6.040562],[100.085757,6.464489],[100.259596,6.642825],[101.075516,6.204867]]],[[[118.618321,4.478202],[117.882035,4.137551],[117.015214,4.306094],[115.865517,4.306559],[115.519078,3.169238],[115.134037,2.821482],[114.621355,1.430688],[113.80585,1.217549],[112.859809,1.49779],[112.380252,1.410121],[111.797548,0.904441],[111.159138,0.976478],[110.514061,0.773131],[109.830227,1.338136],[109.66326,2.006467],[110.396135,1.663775],[111.168853,1.850637],[111.370081,2.697303],[111.796928,2.885897],[112.995615,3.102395],[113.712935,3.893509],[114.204017,4.525874],[114.659596,4.007637],[114.869557,4.348314],[115.347461,4.316636],[115.4057,4.955228],[115.45071,5.44773],[116.220741,6.143191],[116.725103,6.924771],[117.129626,6.928053],[117.643393,6.422166],[117.689075,5.98749],[118.347691,5.708696],[119.181904,5.407836],[119.110694,5.016128],[118.439727,4.966519],[118.618321,4.478202]]]]},"id":"MYS"}, 10 | {"type":"Feature","properties":{"name":"Mongolia"},"geometry":{"type":"Polygon","coordinates":[[[87.751264,49.297198],[88.805567,49.470521],[90.713667,50.331812],[92.234712,50.802171],[93.104219,50.49529],[94.147566,50.480537],[94.815949,50.013433],[95.814028,49.977467],[97.259728,49.726061],[98.231762,50.422401],[97.82574,51.010995],[98.861491,52.047366],[99.981732,51.634006],[100.88948,51.516856],[102.065223,51.259921],[102.255909,50.510561],[103.676545,50.089966],[104.621552,50.275329],[105.886591,50.406019],[106.888804,50.274296],[107.868176,49.793705],[108.475167,49.282548],[109.402449,49.292961],[110.662011,49.130128],[111.581231,49.377968],[112.89774,49.543565],[114.362456,50.248303],[114.96211,50.140247],[115.485695,49.805177],[116.678801,49.888531],[116.191802,49.134598],[115.485282,48.135383],[115.742837,47.726545],[116.308953,47.85341],[117.295507,47.697709],[118.064143,48.06673],[118.866574,47.74706],[119.772824,47.048059],[119.66327,46.69268],[118.874326,46.805412],[117.421701,46.672733],[116.717868,46.388202],[115.985096,45.727235],[114.460332,45.339817],[113.463907,44.808893],[112.436062,45.011646],[111.873306,45.102079],[111.348377,44.457442],[111.667737,44.073176],[111.829588,43.743118],[111.129682,43.406834],[110.412103,42.871234],[109.243596,42.519446],[107.744773,42.481516],[106.129316,42.134328],[104.964994,41.59741],[104.522282,41.908347],[103.312278,41.907468],[101.83304,42.514873],[100.845866,42.663804],[99.515817,42.524691],[97.451757,42.74889],[96.349396,42.725635],[95.762455,43.319449],[95.306875,44.241331],[94.688929,44.352332],[93.480734,44.975472],[92.133891,45.115076],[90.94554,45.286073],[90.585768,45.719716],[90.970809,46.888146],[90.280826,47.693549],[88.854298,48.069082],[88.013832,48.599463],[87.751264,49.297198]]]},"id":"MNG"}, 11 | {"type":"Feature","properties":{"name":"Myanmar"},"geometry":{"type":"Polygon","coordinates":[[[99.543309,20.186598],[98.959676,19.752981],[98.253724,19.708203],[97.797783,18.62708],[97.375896,18.445438],[97.859123,17.567946],[98.493761,16.837836],[98.903348,16.177824],[98.537376,15.308497],[98.192074,15.123703],[98.430819,14.622028],[99.097755,13.827503],[99.212012,13.269294],[99.196354,12.804748],[99.587286,11.892763],[99.038121,10.960546],[98.553551,9.93296],[98.457174,10.675266],[98.764546,11.441292],[98.428339,12.032987],[98.509574,13.122378],[98.103604,13.64046],[97.777732,14.837286],[97.597072,16.100568],[97.16454,16.928734],[96.505769,16.427241],[95.369352,15.71439],[94.808405,15.803454],[94.188804,16.037936],[94.533486,17.27724],[94.324817,18.213514],[93.540988,19.366493],[93.663255,19.726962],[93.078278,19.855145],[92.368554,20.670883],[92.303234,21.475485],[92.652257,21.324048],[92.672721,22.041239],[93.166128,22.27846],[93.060294,22.703111],[93.286327,23.043658],[93.325188,24.078556],[94.106742,23.850741],[94.552658,24.675238],[94.603249,25.162495],[95.155153,26.001307],[95.124768,26.573572],[96.419366,27.264589],[97.133999,27.083774],[97.051989,27.699059],[97.402561,27.882536],[97.327114,28.261583],[97.911988,28.335945],[98.246231,27.747221],[98.68269,27.508812],[98.712094,26.743536],[98.671838,25.918703],[97.724609,25.083637],[97.60472,23.897405],[98.660262,24.063286],[98.898749,23.142722],[99.531992,22.949039],[99.240899,22.118314],[99.983489,21.742937],[100.416538,21.558839],[101.150033,21.849984],[101.180005,21.436573],[100.329101,20.786122],[100.115988,20.41785],[99.543309,20.186598]]]},"id":"MMR"}, 12 | {"type":"Feature","properties":{"name":"Papua New Guinea"},"geometry":{"type":"MultiPolygon","coordinates":[[[[155.880026,-6.819997],[155.599991,-6.919991],[155.166994,-6.535931],[154.729192,-5.900828],[154.514114,-5.139118],[154.652504,-5.042431],[154.759991,-5.339984],[155.062918,-5.566792],[155.547746,-6.200655],[156.019965,-6.540014],[155.880026,-6.819997]]],[[[151.982796,-5.478063],[151.459107,-5.56028],[151.30139,-5.840728],[150.754447,-6.083763],[150.241197,-6.317754],[149.709963,-6.316513],[148.890065,-6.02604],[148.318937,-5.747142],[148.401826,-5.437756],[149.298412,-5.583742],[149.845562,-5.505503],[149.99625,-5.026101],[150.139756,-5.001348],[150.236908,-5.53222],[150.807467,-5.455842],[151.089672,-5.113693],[151.647881,-4.757074],[151.537862,-4.167807],[152.136792,-4.14879],[152.338743,-4.312966],[152.318693,-4.867661],[151.982796,-5.478063]]],[[[147.191874,-7.388024],[148.084636,-8.044108],[148.734105,-9.104664],[149.306835,-9.071436],[149.266631,-9.514406],[150.038728,-9.684318],[149.738798,-9.872937],[150.801628,-10.293687],[150.690575,-10.582713],[150.028393,-10.652476],[149.78231,-10.393267],[148.923138,-10.280923],[147.913018,-10.130441],[147.135443,-9.492444],[146.567881,-8.942555],[146.048481,-8.067414],[144.744168,-7.630128],[143.897088,-7.91533],[143.286376,-8.245491],[143.413913,-8.983069],[142.628431,-9.326821],[142.068259,-9.159596],[141.033852,-9.117893],[141.017057,-5.859022],[141.00021,-2.600151],[142.735247,-3.289153],[144.583971,-3.861418],[145.27318,-4.373738],[145.829786,-4.876498],[145.981922,-5.465609],[147.648073,-6.083659],[147.891108,-6.614015],[146.970905,-6.721657],[147.191874,-7.388024]]],[[[153.140038,-4.499983],[152.827292,-4.766427],[152.638673,-4.176127],[152.406026,-3.789743],[151.953237,-3.462062],[151.384279,-3.035422],[150.66205,-2.741486],[150.939965,-2.500002],[151.479984,-2.779985],[151.820015,-2.999972],[152.239989,-3.240009],[152.640017,-3.659983],[153.019994,-3.980015],[153.140038,-4.499983]]]]},"id":"PNG"}, 13 | {"type":"Feature","properties":{"name":"Philippines"},"geometry":{"type":"MultiPolygon","coordinates":[[[[126.376814,8.414706],[126.478513,7.750354],[126.537424,7.189381],[126.196773,6.274294],[125.831421,7.293715],[125.363852,6.786485],[125.683161,6.049657],[125.396512,5.581003],[124.219788,6.161355],[123.93872,6.885136],[124.243662,7.36061],[123.610212,7.833527],[123.296071,7.418876],[122.825506,7.457375],[122.085499,6.899424],[121.919928,7.192119],[122.312359,8.034962],[122.942398,8.316237],[123.487688,8.69301],[123.841154,8.240324],[124.60147,8.514158],[124.764612,8.960409],[125.471391,8.986997],[125.412118,9.760335],[126.222714,9.286074],[126.306637,8.782487],[126.376814,8.414706]]],[[[123.982438,10.278779],[123.623183,9.950091],[123.309921,9.318269],[122.995883,9.022189],[122.380055,9.713361],[122.586089,9.981045],[122.837081,10.261157],[122.947411,10.881868],[123.49885,10.940624],[123.337774,10.267384],[124.077936,11.232726],[123.982438,10.278779]]],[[[118.504581,9.316383],[117.174275,8.3675],[117.664477,9.066889],[118.386914,9.6845],[118.987342,10.376292],[119.511496,11.369668],[119.689677,10.554291],[119.029458,10.003653],[118.504581,9.316383]]],[[[121.883548,11.891755],[122.483821,11.582187],[123.120217,11.58366],[123.100838,11.165934],[122.637714,10.741308],[122.00261,10.441017],[121.967367,10.905691],[122.03837,11.415841],[121.883548,11.891755]]],[[[125.502552,12.162695],[125.783465,11.046122],[125.011884,11.311455],[125.032761,10.975816],[125.277449,10.358722],[124.801819,10.134679],[124.760168,10.837995],[124.459101,10.88993],[124.302522,11.495371],[124.891013,11.415583],[124.87799,11.79419],[124.266762,12.557761],[125.227116,12.535721],[125.502552,12.162695]]],[[[121.527394,13.06959],[121.26219,12.20556],[120.833896,12.704496],[120.323436,13.466413],[121.180128,13.429697],[121.527394,13.06959]]],[[[121.321308,18.504065],[121.937601,18.218552],[122.246006,18.47895],[122.336957,18.224883],[122.174279,17.810283],[122.515654,17.093505],[122.252311,16.262444],[121.662786,15.931018],[121.50507,15.124814],[121.728829,14.328376],[122.258925,14.218202],[122.701276,14.336541],[123.950295,13.782131],[123.855107,13.237771],[124.181289,12.997527],[124.077419,12.536677],[123.298035,13.027526],[122.928652,13.55292],[122.671355,13.185836],[122.03465,13.784482],[121.126385,13.636687],[120.628637,13.857656],[120.679384,14.271016],[120.991819,14.525393],[120.693336,14.756671],[120.564145,14.396279],[120.070429,14.970869],[119.920929,15.406347],[119.883773,16.363704],[120.286488,16.034629],[120.390047,17.599081],[120.715867,18.505227],[121.321308,18.504065]]]]},"id":"PHL"}, 14 | {"type":"Feature","properties":{"name":"South Korea"},"geometry":{"type":"Polygon","coordinates":[[[128.349716,38.612243],[129.21292,37.432392],[129.46045,36.784189],[129.468304,35.632141],[129.091377,35.082484],[128.18585,34.890377],[127.386519,34.475674],[126.485748,34.390046],[126.37392,34.93456],[126.559231,35.684541],[126.117398,36.725485],[126.860143,36.893924],[126.174759,37.749686],[126.237339,37.840378],[126.68372,37.804773],[127.073309,38.256115],[127.780035,38.304536],[128.205746,38.370397],[128.349716,38.612243]]]},"id":"KOR"}, 15 | {"type":"Feature","properties":{"name":"Taiwan"},"geometry":{"type":"Polygon","coordinates":[[[121.777818,24.394274],[121.175632,22.790857],[120.74708,21.970571],[120.220083,22.814861],[120.106189,23.556263],[120.69468,24.538451],[121.495044,25.295459],[121.951244,24.997596],[121.777818,24.394274]]]},"id":"TWN"}, 16 | {"type":"Feature","properties":{"name":"Thailand"},"geometry":{"type":"Polygon","coordinates":[[[102.584932,12.186595],[101.687158,12.64574],[100.83181,12.627085],[100.978467,13.412722],[100.097797,13.406856],[100.018733,12.307001],[99.478921,10.846367],[99.153772,9.963061],[99.222399,9.239255],[99.873832,9.207862],[100.279647,8.295153],[100.459274,7.429573],[101.017328,6.856869],[101.623079,6.740622],[102.141187,6.221636],[101.814282,5.810808],[101.154219,5.691384],[101.075516,6.204867],[100.259596,6.642825],[100.085757,6.464489],[99.690691,6.848213],[99.519642,7.343454],[98.988253,7.907993],[98.503786,8.382305],[98.339662,7.794512],[98.150009,8.350007],[98.25915,8.973923],[98.553551,9.93296],[99.038121,10.960546],[99.587286,11.892763],[99.196354,12.804748],[99.212012,13.269294],[99.097755,13.827503],[98.430819,14.622028],[98.192074,15.123703],[98.537376,15.308497],[98.903348,16.177824],[98.493761,16.837836],[97.859123,17.567946],[97.375896,18.445438],[97.797783,18.62708],[98.253724,19.708203],[98.959676,19.752981],[99.543309,20.186598],[100.115988,20.41785],[100.548881,20.109238],[100.606294,19.508344],[101.282015,19.462585],[101.035931,18.408928],[101.059548,17.512497],[102.113592,18.109102],[102.413005,17.932782],[102.998706,17.961695],[103.200192,18.309632],[103.956477,18.240954],[104.716947,17.428859],[104.779321,16.441865],[105.589039,15.570316],[105.544338,14.723934],[105.218777,14.273212],[104.281418,14.416743],[102.988422,14.225721],[102.348099,13.394247],[102.584932,12.186595]]]},"id":"THA"}, 17 | {"type":"Feature","properties":{"name":"East Timor"},"geometry":{"type":"Polygon","coordinates":[[[124.968682,-8.89279],[125.086246,-8.656887],[125.947072,-8.432095],[126.644704,-8.398247],[126.957243,-8.273345],[127.335928,-8.397317],[126.967992,-8.668256],[125.925885,-9.106007],[125.08852,-9.393173],[125.07002,-9.089987],[124.968682,-8.89279]]]},"id":"TLS"}, 18 | {"type":"Feature","properties":{"name":"Vietnam"},"geometry":{"type":"Polygon","coordinates":[[[108.05018,21.55238],[106.715068,20.696851],[105.881682,19.75205],[105.662006,19.058165],[106.426817,18.004121],[107.361954,16.697457],[108.269495,16.079742],[108.877107,15.276691],[109.33527,13.426028],[109.200136,11.666859],[108.36613,11.008321],[107.220929,10.364484],[106.405113,9.53084],[105.158264,8.59976],[104.795185,9.241038],[105.076202,9.918491],[104.334335,10.486544],[105.199915,10.88931],[106.24967,10.961812],[105.810524,11.567615],[107.491403,12.337206],[107.614548,13.535531],[107.382727,14.202441],[107.564525,15.202173],[107.312706,15.908538],[106.556008,16.604284],[105.925762,17.485315],[105.094598,18.666975],[103.896532,19.265181],[104.183388,19.624668],[104.822574,19.886642],[104.435,20.758733],[103.203861,20.766562],[102.754896,21.675137],[102.170436,22.464753],[102.706992,22.708795],[103.504515,22.703757],[104.476858,22.81915],[105.329209,23.352063],[105.811247,22.976892],[106.725403,22.794268],[106.567273,22.218205],[107.04342,21.811899],[108.05018,21.55238]]]},"id":"VNM"} 19 | ]} -------------------------------------------------------------------------------- /js/barChart.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | ///////////////////////////////// Bar Chart /////////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | var barScale = d3.scale.linear(); 6 | 7 | var xAxis = d3.svg.axis() 8 | .orient("bottom"); 9 | 10 | var yAxis = d3.svg.axis() 11 | .orient("left") 12 | .ticks(8); //Set rough # of ticks 13 | 14 | var barHeight = 17, 15 | barChartHeight = 330, 16 | barTitleText; 17 | 18 | function initiateBarChart() { 19 | 20 | //Remove all previous elements of the bar chart 21 | barChart.selectAll("g").remove(); 22 | barWrappingOther.selectAll("g").remove(); 23 | 24 | //Set the bar chart dimension and location 25 | barChart.attr("width", 300) 26 | .attr("height", barChartHeight) 27 | .attr("transform","translate(650,220)") 28 | .style("visibility","visible") 29 | .style("opacity",0) 30 | .transition().duration(2000) 31 | .style("opacity",1); 32 | 33 | barWrappingOther.attr("width", 300) 34 | .attr("height", 20) 35 | .attr("transform","translate(650, " + (220 + barChartHeight) +")") 36 | .style("visibility","visible") 37 | .style("opacity",0) 38 | .transition().duration(2000) 39 | .style("opacity",1); 40 | 41 | //Create the bar scale for population as the initialization 42 | barScale 43 | .range([0, 200]) 44 | .domain([0,d3.max(countries, function(d) {return d.pop_2010;})]); 45 | 46 | //Set up axes 47 | xAxis 48 | .ticks(5) 49 | .scale(barScale) 50 | .tickFormat(numFormatSI); 51 | 52 | //Create a group for each bar 53 | var bar = barChart.selectAll("g") 54 | .data(countries) 55 | .enter().append("g") 56 | .attr("class", "barWrapper") 57 | .style("visibility","visible") 58 | .attr("transform", function(d, i) { return "translate(75," + (20 + (d.rank_pop-1) * (barHeight)) + ")"; }) 59 | .on("mouseover", highlight) 60 | .on("mouseout", showAll); 61 | 62 | //Create a white bar to give better mousover and mouseout events 63 | bar.append("rect") 64 | .attr("class","background") 65 | .attr("x", -100) 66 | .attr("width", 300) 67 | .attr("height", barHeight) 68 | .style("fill", "white"); 69 | 70 | //Already append a few lines for later 71 | bar.append("line") 72 | .attr("class", "line-connect") 73 | .style("stroke-width", 1) 74 | .attr("stroke", "#858483") 75 | .style("opacity", 0); 76 | 77 | //Create the 2010 reddish bars 78 | bar.append("rect") 79 | .attr("class","city_2010") 80 | .style("fill","#DA6761") 81 | .style("fill-opacity", 0.8) 82 | .attr("width", 0) 83 | .attr("height", barHeight - 2); 84 | 85 | //Create the 2000 grey bars 86 | bar.append("rect") 87 | .attr("class","city_2000") 88 | .style("fill","#858483") 89 | .style("opacity", 0.8) 90 | .attr("width", 0) 91 | .attr("height", barHeight - 2); 92 | 93 | //Append country name 94 | bar.append("text") 95 | .attr("class", "barLabels") 96 | .attr("x", -10) 97 | .attr("y", 11) 98 | .style("text-anchor", "end") 99 | .style("font-size", 10) 100 | .style("font-weight", 300) 101 | .style("fill","#292929") 102 | .style("font-family", "'Open Sans', sans-serif") 103 | .text(function(d) { return d.country; }); 104 | 105 | //Append the x-axis 106 | barWrappingOther.append("g") 107 | .attr("class", "x axis") 108 | .attr("transform", "translate(75," + 10 + ")"); 109 | 110 | //Append the y-axis 111 | barWrappingOther.append("g") 112 | .attr("class", "y axis") 113 | .attr("transform", "translate(65," + -barChartHeight + ")"); 114 | 115 | var barTitle = barChart.append("g") 116 | .append("text") 117 | .attr("class","barTitle titleTop") 118 | .style("visibility","visible") 119 | .attr("transform", "translate(175,5)") 120 | .style("text-anchor", "middle"); 121 | 122 | //Create the slopegraph based on the dimension selected 123 | if (rVar == "pop") {totalPopulationBarGraph();}; 124 | if (rVar == "land") {totalLandBarGraph();}; 125 | if (rVar == "density") {totalDensityBarGraph();}; 126 | }//initiateBarChart 127 | 128 | //Update the bar graph to population 129 | function totalPopulationBarGraph() { 130 | rVar = "pop"; 131 | barTitleText = "Urban population"; 132 | updateBar(); 133 | }//totalPopulationBarGraph 134 | 135 | //Update the bar graph to land 136 | function totalLandBarGraph() { 137 | rVar = "land"; 138 | barTitleText = "Urban land [in sq. km.]"; 139 | updateBar(); 140 | }//totalLandBarGraph 141 | 142 | //Update the bar graph to density 143 | function totalDensityBarGraph() { 144 | rVar = "density"; 145 | barTitleText = "Avg. urban population density [in persons/sq. km]"; 146 | updateBar(); 147 | }//totalDensityBarGraph 148 | 149 | //Update the bar graph to the chosen dimension in the buttons 150 | function updateBar() { 151 | barScale.domain([0,d3.max(countries, function(d) {return eval("d." + rVar + "_2010");})]) 152 | xAxis.scale(barScale); 153 | 154 | barChart.selectAll(".barWrapper") 155 | .style("visibility","visible") 156 | .transition().duration(1000) 157 | .attr("transform", function(d, i) { return "translate(75," + (20 + eval("d.rank_" + rVar + "-1") * barHeight) + ")"; }); 158 | 159 | barChart.selectAll(".city_2010") 160 | .transition().duration(1000) 161 | .attr("width", function(d) {return barScale(eval("d." + rVar + "_2010"));}) 162 | 163 | barChart.selectAll(".city_2000") 164 | .transition().duration(1000) 165 | .attr("width", function(d) {return barScale(eval("d." + rVar + "_2000"));}) 166 | 167 | //Update the x axis 168 | barWrappingOther.select(".x.axis") 169 | .transition().duration(1000) 170 | .call(xAxis); 171 | 172 | barChart.selectAll(".barTitle") 173 | .text(barTitleText); 174 | 175 | }//updateBar 176 | -------------------------------------------------------------------------------- /js/countries.js: -------------------------------------------------------------------------------- 1 | var countries = [ 2 | { 3 | "rank_pop": 1, 4 | "country": "China", 5 | "rank_land": 1, 6 | "land_2000": 65741, 7 | "land_2010": 89389, 8 | "land_increase_yearly_rate": 3.12, 9 | "land_total": 9453309, 10 | "urban_land_perc_2000": 0.7, 11 | "urban_land_perc_2010": 0.95, 12 | "pop_2000": 345844670, 13 | "pop_2010": 477232691, 14 | "pop_increase_yearly_rate": 3.27, 15 | "pop_2000_total": 1247009000, 16 | "pop_2010_total": 1321567200, 17 | "rank_pop_perc": 8, 18 | "pop_perc_2000": 0.28, 19 | "pop_perc_2010": 0.36, 20 | "rank_density": 11, 21 | "density_2000": 5261, 22 | "density_2010": 5339, 23 | "gdp_2000": 2860.8, 24 | "gdp_2010": 9043.8, 25 | "type_country": "upper-middle-income" 26 | }, 27 | { 28 | "rank_pop": 2, 29 | "country": "Indonesia", 30 | "rank_land": 3, 31 | "land_2000": 8939, 32 | "land_2010": 10013, 33 | "land_increase_yearly_rate": 1.14, 34 | "land_total": 1890973, 35 | "urban_land_perc_2000": 0.47, 36 | "urban_land_perc_2010": 0.53, 37 | "pop_2000": 66555373, 38 | "pop_2010": 94329271, 39 | "pop_increase_yearly_rate": 3.55, 40 | "pop_2000_total": 208938698, 41 | "pop_2010_total": 240676485, 42 | "rank_pop_perc": 7, 43 | "pop_perc_2000": 0.32, 44 | "pop_perc_2010": 0.39, 45 | "rank_density": 3, 46 | "density_2000": 7446, 47 | "density_2010": 9421, 48 | "gdp_2000": 4400.6, 49 | "gdp_2010": 7864.4, 50 | "type_country": "lower-middle-income" 51 | }, 52 | { 53 | "rank_pop": 3, 54 | "country": "Japan", 55 | "rank_land": 2, 56 | "land_2000": 15539, 57 | "land_2010": 16165, 58 | "land_increase_yearly_rate": 0.4, 59 | "land_total": 372468, 60 | "urban_land_perc_2000": 4.17, 61 | "urban_land_perc_2010": 4.34, 62 | "pop_2000": 66510957, 63 | "pop_2010": 76527309, 64 | "pop_increase_yearly_rate": 1.41, 65 | "pop_2000_total": 126870000, 66 | "pop_2010_total": 127450459, 67 | "rank_pop_perc": 3, 68 | "pop_perc_2000": 0.52, 69 | "pop_perc_2010": 0.6, 70 | "rank_density": 13, 71 | "density_2000": 4280, 72 | "density_2010": 4734, 73 | "gdp_2000": 25930.5, 74 | "gdp_2010": 33916.5, 75 | "type_country": "high-income" 76 | }, 77 | { 78 | "rank_pop": 4, 79 | "country": "Republic of Korea", 80 | "rank_land": 7, 81 | "land_2000": 2233, 82 | "land_2010": 2539, 83 | "land_increase_yearly_rate": 1.29, 84 | "land_total": 100229, 85 | "urban_land_perc_2000": 2.23, 86 | "urban_land_perc_2010": 2.53, 87 | "pop_2000": 23629279, 88 | "pop_2010": 26682593, 89 | "pop_increase_yearly_rate": 1.22, 90 | "pop_2000_total": 47008111, 91 | "pop_2010_total": 49410366, 92 | "rank_pop_perc": 5, 93 | "pop_perc_2000": 0.5, 94 | "pop_perc_2010": 0.54, 95 | "rank_density": 1, 96 | "density_2000": 10584, 97 | "density_2010": 10511, 98 | "gdp_2000": 18123.2, 99 | "gdp_2010": 30423, 100 | "type_country": "high-income" 101 | }, 102 | { 103 | "rank_pop": 5, 104 | "country": "Philippines", 105 | "rank_land": 8, 106 | "land_2000": 1779, 107 | "land_2010": 2257, 108 | "land_increase_yearly_rate": 2.41, 109 | "land_total": 295988, 110 | "urban_land_perc_2000": 0.6, 111 | "urban_land_perc_2010": 0.76, 112 | "pop_2000": 16829863, 113 | "pop_2010": 23280178, 114 | "pop_increase_yearly_rate": 3.3, 115 | "pop_2000_total": 77651848, 116 | "pop_2010_total": 93444322, 117 | "rank_pop_perc": 11, 118 | "pop_perc_2000": 0.22, 119 | "pop_perc_2010": 0.25, 120 | "rank_density": 2, 121 | "density_2000": 9463, 122 | "density_2010": 10314, 123 | "gdp_2000": 3362.8, 124 | "gdp_2010": 5500.2, 125 | "type_country": "lower-middle-income" 126 | }, 127 | { 128 | "rank_pop": 6, 129 | "country": "Vietnam", 130 | "rank_land": 5, 131 | "land_2000": 2208, 132 | "land_2010": 2924, 133 | "land_increase_yearly_rate": 2.85, 134 | "land_total": 328385, 135 | "urban_land_perc_2000": 0.67, 136 | "urban_land_perc_2010": 0.89, 137 | "pop_2000": 15088917, 138 | "pop_2010": 22597771, 139 | "pop_increase_yearly_rate": 4.12, 140 | "pop_2000_total": 77630900, 141 | "pop_2010_total": 86932500, 142 | "rank_pop_perc": 10, 143 | "pop_perc_2000": 0.19, 144 | "pop_perc_2010": 0.26, 145 | "rank_density": 7, 146 | "density_2000": 6835, 147 | "density_2010": 7729, 148 | "gdp_2000": 2100.2, 149 | "gdp_2010": 4395.6, 150 | "type_country": "lower-middle-income" 151 | }, 152 | { 153 | "rank_pop": 7, 154 | "country": "Malaysia", 155 | "rank_land": 4, 156 | "land_2000": 3924, 157 | "land_2010": 4572, 158 | "land_increase_yearly_rate": 1.54, 159 | "land_total": 329424, 160 | "urban_land_perc_2000": 1.19, 161 | "urban_land_perc_2010": 1.39, 162 | "pop_2000": 10154126, 163 | "pop_2010": 14959677, 164 | "pop_increase_yearly_rate": 3.95, 165 | "pop_2000_total": 23420751, 166 | "pop_2010_total": 28275835, 167 | "rank_pop_perc": 6, 168 | "pop_perc_2000": 0.43, 169 | "pop_perc_2010": 0.53, 170 | "rank_density": 16, 171 | "density_2000": 2588, 172 | "density_2010": 3272, 173 | "gdp_2000": 12440, 174 | "gdp_2010": 19985.9, 175 | "type_country": "upper-middle-income" 176 | }, 177 | { 178 | "rank_pop": 8, 179 | "country": "Taiwan, China", 180 | "rank_land": 9, 181 | "land_2000": 1690, 182 | "land_2010": 1938, 183 | "land_increase_yearly_rate": 1.37, 184 | "land_total": 36224, 185 | "urban_land_perc_2000": 4.67, 186 | "urban_land_perc_2010": 5.35, 187 | "pop_2000": 13368812, 188 | "pop_2010": 14319702, 189 | "pop_increase_yearly_rate": 0.69, 190 | "pop_2000_total": 22301000, 191 | "pop_2010_total": 23162000, 192 | "rank_pop_perc": 2, 193 | "pop_perc_2000": 0.6, 194 | "pop_perc_2010": 0.62, 195 | "rank_density": 9, 196 | "density_2000": 7909, 197 | "density_2010": 7391, 198 | "gdp_2000": 0, 199 | "gdp_2010": 0, 200 | "type_country": "high-income" 201 | }, 202 | { 203 | "rank_pop": 9, 204 | "country": "Thailand", 205 | "rank_land": 6, 206 | "land_2000": 2359, 207 | "land_2010": 2705, 208 | "land_increase_yearly_rate": 1.38, 209 | "land_total": 514093, 210 | "urban_land_perc_2000": 0.46, 211 | "urban_land_perc_2010": 0.53, 212 | "pop_2000": 9336866, 213 | "pop_2010": 11750518, 214 | "pop_increase_yearly_rate": 2.33, 215 | "pop_2000_total": 62343379, 216 | "pop_2010_total": 66402316, 217 | "rank_pop_perc": 12, 218 | "pop_perc_2000": 0.15, 219 | "pop_perc_2010": 0.18, 220 | "rank_density": 14, 221 | "density_2000": 3958, 222 | "density_2010": 4344, 223 | "gdp_2000": 7085.2, 224 | "gdp_2010": 12562.4, 225 | "type_country": "upper-middle-income" 226 | }, 227 | { 228 | "rank_pop": 10, 229 | "country": "Myanmar", 230 | "rank_land": 10, 231 | "land_2000": 762, 232 | "land_2010": 828, 233 | "land_increase_yearly_rate": 0.83, 234 | "land_total": 670747, 235 | "urban_land_perc_2000": 0.11, 236 | "urban_land_perc_2010": 0.12, 237 | "pop_2000": 4696086, 238 | "pop_2010": 6214646, 239 | "pop_increase_yearly_rate": 2.84, 240 | "pop_2000_total": 48453000, 241 | "pop_2010_total": 51931231, 242 | "rank_pop_perc": 14, 243 | "pop_perc_2000": 0.1, 244 | "pop_perc_2010": 0.12, 245 | "rank_density": 8, 246 | "density_2000": 6163, 247 | "density_2010": 7510, 248 | "gdp_2000": 0, 249 | "gdp_2010": 0, 250 | "type_country": "low-income" 251 | }, 252 | { 253 | "rank_pop": 11, 254 | "country": "Singapore", 255 | "rank_land": 11, 256 | "land_2000": 337, 257 | "land_2010": 404, 258 | "land_increase_yearly_rate": 1.81, 259 | "land_total": 755, 260 | "urban_land_perc_2000": 44.64, 261 | "urban_land_perc_2010": 53.41, 262 | "pop_2000": 2539073, 263 | "pop_2010": 3412239, 264 | "pop_increase_yearly_rate": 3, 265 | "pop_2000_total": 4027900, 266 | "pop_2010_total": 5076700, 267 | "rank_pop_perc": 1, 268 | "pop_perc_2000": 0.63, 269 | "pop_perc_2010": 0.67, 270 | "rank_density": 6, 271 | "density_2000": 7529, 272 | "density_2010": 8457, 273 | "gdp_2000": 40813.2, 274 | "gdp_2010": 70364.2, 275 | "type_country": "high-income" 276 | }, 277 | { 278 | "rank_pop": 12, 279 | "country": "DPR Korea", 280 | "rank_land": 12, 281 | "land_2000": 306, 282 | "land_2010": 321, 283 | "land_increase_yearly_rate": 0.48, 284 | "land_total": 122755, 285 | "urban_land_perc_2000": 0.25, 286 | "urban_land_perc_2010": 0.26, 287 | "pop_2000": 2623722, 288 | "pop_2010": 2918281, 289 | "pop_increase_yearly_rate": 1.07, 290 | "pop_2000_total": 22840225, 291 | "pop_2010_total": 24500520, 292 | "rank_pop_perc": 15, 293 | "pop_perc_2000": 0.11, 294 | "pop_perc_2010": 0.12, 295 | "rank_density": 4, 296 | "density_2000": 8566, 297 | "density_2010": 9081, 298 | "gdp_2000": 0, 299 | "gdp_2010": 0, 300 | "type_country": "low-income" 301 | }, 302 | { 303 | "rank_pop": 13, 304 | "country": "Cambodia", 305 | "rank_land": 15, 306 | "land_2000": 107, 307 | "land_2010": 164, 308 | "land_increase_yearly_rate": 4.29, 309 | "land_total": 181354, 310 | "urban_land_perc_2000": 0.06, 311 | "urban_land_perc_2010": 0.09, 312 | "pop_2000": 917645, 313 | "pop_2010": 1405381, 314 | "pop_increase_yearly_rate": 4.35, 315 | "pop_2000_total": 12222871, 316 | "pop_2010_total": 14364931, 317 | "rank_pop_perc": 16, 318 | "pop_perc_2000": 0.08, 319 | "pop_perc_2010": 0.1, 320 | "rank_density": 5, 321 | "density_2000": 8546, 322 | "density_2010": 8596, 323 | "gdp_2000": 1084.3, 324 | "gdp_2010": 2462.2, 325 | "type_country": "low-income" 326 | }, 327 | { 328 | "rank_pop": 14, 329 | "country": "Mongolia", 330 | "rank_land": 13, 331 | "land_2000": 210, 332 | "land_2010": 271, 333 | "land_increase_yearly_rate": 2.59, 334 | "land_total": 1566250, 335 | "urban_land_perc_2000": 0.01, 336 | "urban_land_perc_2010": 0.02, 337 | "pop_2000": 631407, 338 | "pop_2010": 926999, 339 | "pop_increase_yearly_rate": 3.91, 340 | "pop_2000_total": 2397473, 341 | "pop_2010_total": 2712738, 342 | "rank_pop_perc": 9, 343 | "pop_perc_2000": 0.26, 344 | "pop_perc_2010": 0.34, 345 | "rank_density": 15, 346 | "density_2000": 3008, 347 | "density_2010": 3419, 348 | "gdp_2000": 3099.5, 349 | "gdp_2010": 6344.5, 350 | "type_country": "lower-middle-income" 351 | }, 352 | { 353 | "rank_pop": 15, 354 | "country": "Lao PDR", 355 | "rank_land": 16, 356 | "land_2000": 48, 357 | "land_2010": 97, 358 | "land_increase_yearly_rate": 7.32, 359 | "land_total": 229878, 360 | "urban_land_perc_2000": 0.02, 361 | "urban_land_perc_2010": 0.04, 362 | "pop_2000": 134290, 363 | "pop_2010": 307044, 364 | "pop_increase_yearly_rate": 8.62, 365 | "pop_2000_total": 5388281, 366 | "pop_2010_total": 6395713, 367 | "rank_pop_perc": 17, 368 | "pop_perc_2000": 0.02, 369 | "pop_perc_2010": 0.05, 370 | "rank_density": 17, 371 | "density_2000": 2809, 372 | "density_2010": 3167, 373 | "gdp_2000": 1844.4, 374 | "gdp_2010": 3821.9, 375 | "type_country": "lower-middle-income" 376 | }, 377 | { 378 | "rank_pop": 16, 379 | "country": "Papua New Guinea", 380 | "rank_land": 17, 381 | "land_2000": 43, 382 | "land_2010": 44, 383 | "land_increase_yearly_rate": 0.27, 384 | "land_total": 462840, 385 | "urban_land_perc_2000": 0.01, 386 | "urban_land_perc_2010": 0.01, 387 | "pop_2000": 190406, 388 | "pop_2010": 233051, 389 | "pop_increase_yearly_rate": 2.04, 390 | "pop_2000_total": 5379226, 391 | "pop_2010_total": 6858945, 392 | "rank_pop_perc": 18, 393 | "pop_perc_2000": 0.04, 394 | "pop_perc_2010": 0.03, 395 | "rank_density": 12, 396 | "density_2000": 4428, 397 | "density_2010": 5274, 398 | "gdp_2000": 1474.2, 399 | "gdp_2010": 2071.5, 400 | "type_country": "lower-middle-income" 401 | }, 402 | { 403 | "rank_pop": 17, 404 | "country": "Brunei", 405 | "rank_land": 14, 406 | "land_2000": 144, 407 | "land_2010": 180, 408 | "land_increase_yearly_rate": 2.24, 409 | "land_total": 5765, 410 | "urban_land_perc_2000": 2.51, 411 | "urban_land_perc_2010": 3.13, 412 | "pop_2000": 155900, 413 | "pop_2010": 230300, 414 | "pop_increase_yearly_rate": 3.98, 415 | "pop_2000_total": 331801, 416 | "pop_2010_total": 400569, 417 | "rank_pop_perc": 4, 418 | "pop_perc_2000": 0.47, 419 | "pop_perc_2010": 0.57, 420 | "rank_density": 18, 421 | "density_2000": 1079, 422 | "density_2010": 1278, 423 | "gdp_2000": 59030.7, 424 | "gdp_2010": 69208.2, 425 | "type_country": "high-income" 426 | }, 427 | { 428 | "rank_pop": 18, 429 | "country": "Timor-Leste", 430 | "rank_land": 18, 431 | "land_2000": 28, 432 | "land_2010": 28, 433 | "land_increase_yearly_rate": 0, 434 | "land_total": 15007, 435 | "urban_land_perc_2000": 0.19, 436 | "urban_land_perc_2010": 0.19, 437 | "pop_2000": 115901, 438 | "pop_2010": 180734, 439 | "pop_increase_yearly_rate": 4.54, 440 | "pop_2000_total": 853585, 441 | "pop_2010_total": 1066409, 442 | "rank_pop_perc": 13, 443 | "pop_perc_2000": 0.14, 444 | "pop_perc_2010": 0.17, 445 | "rank_density": 10, 446 | "density_2000": 4085, 447 | "density_2010": 6369, 448 | "gdp_2000": 1047.6, 449 | "gdp_2010": 1741.2, 450 | "type_country": "lower-middle-income" 451 | }, 452 | ] 453 | -------------------------------------------------------------------------------- /js/dotHistogram.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | //////////////////////////// Dot Histogram //////////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | var dotScaleY = d3.scale.linear(), 6 | dotScaleX = d3.scale.linear().range([75,575]), 7 | dotLocation = 550, 8 | stepSize, 9 | perc, 10 | stepSize, 11 | stepper, 12 | maxNum = 3, 13 | legend, 14 | legendTitle, 15 | dotTitle, 16 | firstDot = true, 17 | ranking_pop = [], 18 | ranking_land = []. 19 | ranking_density = []; 20 | 21 | var xDotAxis = d3.svg.axis() 22 | .orient("bottom") 23 | .ticks(8); //Set rough # of ticks 24 | 25 | var color = d3.scale.threshold(); 26 | 27 | function callDotHistogram() { 28 | 29 | setTimeout(function() {counter = 7;}, 1000); 30 | firstDot = true; 31 | 32 | ////////////////////////////////////////////////////// 33 | ////////////////// Hide & Remove ///////////////////// 34 | ////////////////////////////////////////////////////// 35 | 36 | //Activate the back button 37 | d3.select("#clickerBack").classed("activeButton",true); 38 | d3.select("#clickerBack").classed("inactiveButton",false); 39 | //Activate the front button 40 | d3.select("#clickerFront").classed("activeButton",true); 41 | d3.select("#clickerFront").classed("inactiveButton",false); 42 | //Change text of front button 43 | d3.select("#clickerFront").html("Continue"); 44 | 45 | //Reset the progress bar 46 | resetProgressBar(); 47 | 48 | //Set the progress circles 49 | setCircleProgress(6); 50 | 51 | 52 | //Remove the bar chart to the right - if present 53 | barChart.selectAll("g").transition().remove(); 54 | barWrappingOther.selectAll("g").transition().remove(); 55 | 56 | //Remove the two bars - if present 57 | startBarChart.selectAll("g").remove(); 58 | 59 | //Remove the intro explanation 60 | d3.select("#explanationIntro") 61 | .transition().duration(1000) 62 | .style("opacity",0) 63 | .call(endall, function() { 64 | d3.select("#explanationIntro") 65 | .style("visibility","hidden"); 66 | }); 67 | 68 | //Make text & call-out disappear - if present 69 | d3.select("#explanation") 70 | .transition().duration(1000) 71 | .style("opacity",0) 72 | .call(endall, function() { 73 | d3.select("#explanation") 74 | .style("visibility","hidden"); 75 | }); 76 | 77 | //Remove map 78 | map.selectAll(".geo-path") 79 | .transition().duration(2000) 80 | .style("stroke-opacity", 0) 81 | .style("fill-opacity", 0) 82 | .call(endall, function() { 83 | map.selectAll(".geo-path") 84 | .attr("visibility", "hidden"); 85 | }); 86 | 87 | //Remove slopegraph elements - if present 88 | slopes.selectAll(".slopes").remove(); 89 | text2000.selectAll("text").remove(); 90 | text2010.selectAll("text").remove(); 91 | slopeTitles.selectAll("text").remove(); 92 | 93 | //Show the buttons 94 | d3.select(".btn-group") 95 | .style("visibility", "visible"); 96 | 97 | //Show the text & button on the right 98 | d3.select("#section") 99 | .transition().delay(100) 100 | .style("opacity",0) 101 | .call(endall, function() { 102 | d3.select("#section") 103 | .style("visibility","visible"); 104 | 105 | //Change title in top right corner 106 | d3.select("#sectionTitle") 107 | .html("Rapid growth within one decade"); 108 | //Change text in top right corner 109 | d3.select("#sectionText") 110 | .html('

These plots show the rapid growth in land and population within the cities. Growth may lead to numerous economic opportunities. However, it also forces urban policy makers and planners to rethink the design of their cities. The arrangement of future infrastructure can already be a crucial decision. Each city has its own challenges and opportunities and each county its own way of growing

' + 111 | '

Click on the buttons below to see the differences of the urban population, urban land or urban population density per city or hover over the plots to get more detailed information

'); 112 | 113 | }) 114 | .transition().duration(1000) 115 | .style("opacity",1); 116 | 117 | //Show bar chart again 118 | setTimeout(initiateBarChart, 600); 119 | 120 | //Call slopegraph 121 | setTimeout(dotHistogram, 1100); 122 | 123 | } 124 | 125 | function dotHistogram() { 126 | 127 | modus = "Dot"; 128 | 129 | ////////////////////////////////////////////////////// 130 | ////////////////////// Initialize //////////////////// 131 | ////////////////////////////////////////////////////// 132 | 133 | //Create domains of the scale 134 | dotScaleY 135 | .range([dotLocation,(dotLocation-500)]) 136 | .domain([1,100]); 137 | 138 | ////////////////////////////////////////////////////// 139 | ////////////////////// Build axes //////////////////// 140 | ////////////////////////////////////////////////////// 141 | 142 | //Remove any previous axis & legend 143 | dotWrapper.selectAll("g").remove(); 144 | dotWrapper.selectAll("text").remove(); 145 | 146 | //Set the format of the y axis 147 | xDotAxis.tickFormat(numFormatPercent); 148 | 149 | //Put in the right location 150 | dotWrapper.append("g") 151 | .attr("class", "x axis") 152 | .attr("transform", "translate(" + 0 + "," + (dotLocation+10) + ")") 153 | .style("opacity", 0); 154 | 155 | //Set up X axis label 156 | dotWrapper.append("text") 157 | .attr("class", "x label titleTop") 158 | .attr("text-anchor", "middle") 159 | .attr("x", (75 + (575-75)/2)) 160 | .attr("y", dotLocation + 60) 161 | .style("font-size", "18px") 162 | .style("opacity", 0); 163 | 164 | ////////////////// y axis //////////////////// 165 | var yDotAxis = d3.svg.axis() 166 | .orient("left") 167 | .ticks(8) //Set rough # of ticks 168 | .scale(dotScaleY); 169 | 170 | //Put in the right location 171 | dotWrapper.append("g") 172 | .attr("class", "y axis") 173 | .attr("transform", "translate(" + 65 + "," + 0 + ")") 174 | .style("opacity", 0) 175 | .transition().duration(1000).delay(2000) 176 | .style("opacity", 1) 177 | .call(yDotAxis); 178 | dotWrapper.selectAll(".y.axis text") 179 | .style("font-size", "10px"); 180 | 181 | //Set up Y axis label 182 | dotWrapper.append("text") 183 | .attr("class", "y label titleTop") 184 | .attr("text-anchor", "middle") 185 | //.attr("transform", "rotate(-90)") 186 | //.attr("x", -180) 187 | //.attr("y", 85) 188 | .attr("x", 65) 189 | .attr("y", 35) 190 | .style("font-size", "12px") 191 | .style("opacity", 0) 192 | .text("Number of cities") 193 | .transition().duration(1000).delay(2000) 194 | .style("opacity", 1); 195 | 196 | ////////////////////////////////////////////////////// 197 | //////////////////// Set color /////////////////////// 198 | ////////////////////////////////////////////////////// 199 | 200 | //Create color scale 201 | //var hexColors = ['#631b17','#7f2d28','#9d403a','#bb534e','#da6761']; 202 | //var hexColors = ['rgb(252,187,161)','rgb(252,146,114)','rgb(251,106,74)','rgb(222,45,38)','rgb(165,15,21)']; 203 | //var popData = []; 204 | //data.forEach(function(d, i) { 205 | // popData[i] = d.pop_2010; 206 | //}) 207 | //var color = d3.scale.linear() 208 | // .domain([d3.quantile(popData, 0),d3.quantile(popData, 0.25),d3.quantile(popData, 0.5),d3.quantile(popData, 0.75),d3.quantile(popData, 1)]) 209 | // .range(hexColors.reverse()); 210 | //var hexColors = ["#fcbba1","#67000d"]; 211 | //var color = d3.scale.log() 212 | // .domain(d3.extent(data, function(d) {return d.pop_2010;})) 213 | // .range(hexColors); 214 | //var color = d3.scale.quantile() 215 | // .domain(popData) 216 | // .range(hexColors.reverse()); 217 | 218 | //var hexColors = ["#63A69F","#F2E1AC","#F2836B","#cb181d"]; 219 | var hexColors = ["#fcbba1","#fb6a4a","#cb181d","#67000d"]; 220 | color.range(hexColors); 221 | 222 | ////////////////////////////////////////////////////// 223 | ///////////////// Initiate legend //////////////////// 224 | ////////////////////////////////////////////////////// 225 | 226 | //Adding legend 227 | legendWrapper = dotWrapper.append("g") 228 | .attr("transform","translate(460, 200)") 229 | .style("opacity", 0); 230 | 231 | legend = legendWrapper 232 | .selectAll("g.legend") 233 | .data(color.range()) 234 | .enter().append("g") 235 | .attr("class", "legend"); 236 | 237 | //Create title of Legend 238 | legendWrapper.append("g") 239 | .attr("class", "legendTitleWrapper") 240 | .append('text') 241 | .attr('x', 0) 242 | .attr('y', 15) 243 | .style("text-anchor", "start") 244 | .attr('class', 'legendTitle titleTop') 245 | .style("font-size", "14px"); 246 | 247 | var ls_w = 15, 248 | ls_h = 15; 249 | 250 | legend.append("rect") 251 | .attr("x", 0) 252 | .attr("y", function(d, i){ return 100 - (i*ls_h) - 2*ls_h;}) 253 | .attr("width", ls_w) 254 | .attr("height", ls_h) 255 | .style("fill", function(d, i) { return d; }) 256 | .style("opacity", 0.8); 257 | 258 | legendText = legend.append("text") 259 | .attr("x", 30) 260 | .attr("y", function(d, i){ return 100 - (i*ls_h) - ls_h - 4;}); 261 | 262 | legendWrapper 263 | .transition().duration(1000).delay(2000) 264 | .style("opacity", 1); 265 | 266 | ////////////////////////////////////////////////////// 267 | ////////////////// Call Dot plot ///////////////////// 268 | ////////////////////////////////////////////////////// 269 | 270 | //Create the dot histogram based on the dimension selected 271 | if (rVar == "pop") totalPopulationDotHisto(); 272 | if (rVar == "land") totalLandDotHisto(); 273 | if (rVar == "density") totalDensityDotHisto(); 274 | 275 | }//dotHistogram 276 | 277 | 278 | //Create the dot histogram based on the dimension selected 279 | function totalPopulationDotHisto() { 280 | stepSize = 0.05; 281 | color.domain([5e5, 1e6, 5e6]); 282 | legendTitle = "Urban population - 2010"; 283 | dotTitle = "Growth in urban population between 2000 and 2010"; 284 | //Set the y-axis scale 285 | dotScaleX.domain(d3.extent(data, function(d) {return d.pop_growth;})); 286 | createDotHisto(); 287 | }//totalPopulationDotHisto 288 | 289 | function totalLandDotHisto() { 290 | stepSize = 0.03; 291 | color.domain([200, 500, 1000]); 292 | legendTitle = "Urban land - 2010"; 293 | dotTitle = "Growth in urban land between 2000 and 2010"; 294 | //Set the y-axis scale 295 | dotScaleX 296 | .domain([d3.min(data, function(d) {return d.land_growth;}), maxNum]) 297 | .clamp(true); 298 | createDotHisto(); 299 | }//totalUrbanLandSlopeGraph 300 | 301 | function totalDensityDotHisto() { 302 | stepSize = 0.02; 303 | color.domain([5000, 10000, 15000]); 304 | legendTitle = "Population density - 2010"; 305 | dotTitle = "Growth in avg. urban population density between 2000 and 2010"; 306 | //Set the y-axis scale 307 | dotScaleX.domain(d3.extent(data, function(d) {return d.density_growth;})); 308 | createDotHisto(); 309 | }//totalDensityDotHisto 310 | 311 | 312 | function createDotHisto() { 313 | 314 | //Create a delay when it is the first instance of the dot histo 315 | var extraDelay = 0; 316 | 317 | stepper = 1/stepSize; 318 | 319 | //Run this only when it is the first time the dot histogram is called 320 | if (firstDot == true) { 321 | 322 | extraDelay = 2000; 323 | 324 | ///////////////////////////////////////////////////////////////////// 325 | ///// Calculate cx positions for each of the 3 dimensions /////////// 326 | ///////////////////////////////////////////////////////////////////// 327 | 328 | ranking_pop = rankLocation(0.05, "pop", 329 | minDomain = d3.min(data, function(d) {return d.pop_growth;}), 330 | maxDomain = d3.max(data, function(d) {return d.pop_growth;})) 331 | 332 | ranking_land = rankLocation(0.03, "land", 333 | minDomain = d3.min(data, function(d) {return d.land_growth;}), 334 | maxDomain = maxNum) 335 | 336 | ranking_density = rankLocation(0.02, "density", 337 | minDomain = d3.min(data, function(d) {return d.density_growth;}), 338 | maxDomain = d3.max(data, function(d) {return d.density_growth;})) 339 | 340 | ////////////////////////////////////////////////////// 341 | ////////////////// Move to one line ////////////////// 342 | ////////////////////////////////////////////////////// 343 | 344 | //Move 2000 cities towards 2010 version 345 | //Then make them disappear 346 | cities2000.selectAll(".city_2000") 347 | .transition().duration(2000) 348 | .attr("cy", dotLocation) 349 | .attr("cx", function(d,i) {return dotScaleX(Math.round(roundHalf(eval("d." + rVar + "_growth"),stepper)*100)/100);}) 350 | .style("fill-opacity", 0.8) 351 | .attr("r", 0); 352 | //Move 2010 cities towards 2000 version 353 | cities2010.selectAll(".city_2010") 354 | .transition().duration(2000) 355 | .attr("cy", dotLocation) 356 | .attr("cx", function(d,i) {return dotScaleX(Math.round(roundHalf(eval("d." + rVar + "_growth"),stepper)*100)/100);}) 357 | .style("fill-opacity", 0.8) 358 | .attr("r", 3); 359 | firstDot = false; 360 | }//if 361 | 362 | //Update the x axis 363 | xDotAxis.scale(dotScaleX); 364 | dotWrapper.selectAll(".x.axis") 365 | .transition().duration(1000).delay(extraDelay) 366 | .style("opacity", 1) 367 | .call(xDotAxis); 368 | dotWrapper.selectAll(".x.axis text") 369 | .style("font-size", "10px"); 370 | 371 | //Change X axis label 372 | dotWrapper.select(".x.label") 373 | .text(dotTitle) 374 | .transition().duration(1000).delay(extraDelay) 375 | .style("opacity", 1); 376 | 377 | //update legend 378 | var legend_labels = ["< " + numFormatSI(color.domain()[0]), 379 | numFormatSI(color.domain()[0]) + " - " + numFormatSI(color.domain()[1]), 380 | numFormatSI(color.domain()[1]) + " - " + numFormatSI(color.domain()[2]), 381 | "> " + numFormatSI(color.domain()[2])]; 382 | legendText 383 | .text(function(d, i){return legend_labels[i];}); 384 | 385 | d3.selectAll(".legendTitle") 386 | .text(legendTitle); 387 | 388 | ////////////////////////////////////////////////////// 389 | /////////////////// Build histogram ////////////////// 390 | ////////////////////////////////////////////////////// 391 | 392 | cities2010.selectAll(".city_2010") 393 | .transition().duration(2000).delay(function(d,i) {return (extraDelay + eval("d.rank_" + rVar)*0.5);}) //Grow from largest cities first 394 | .attr("r", 2) 395 | .style("fill-opacity", 0.9) 396 | .style("fill", function(d) { return color(eval("d." + rVar + "_2010")); }) 397 | .attr("cx", function(d,i) {return dotScaleX(Math.round(roundHalf(eval("d." + rVar + "_growth"), stepper)*100)/100);}) 398 | //.attr("cy", function(d,i) {return locateY(d);}) 399 | .attr("cy", function(d,i) {return eval("ranking_" + rVar + "[i].cy");}) 400 | .call(endall, function() { 401 | cities2010.selectAll(".city_2010") 402 | .on("mouseover", showOneDot) 403 | .on("mouseout", showAllDot); 404 | }); 405 | 406 | }//createDotHisto 407 | 408 | ////////////////////////////////////////////////////// 409 | /////////////////// Extra Functions ////////////////// 410 | ////////////////////////////////////////////////////// 411 | 412 | ////////////////////////////////////////////////////// 413 | /////////////// Dot plot hover options /////////////// 414 | ////////////////////////////////////////////////////// 415 | function showAllDot() { 416 | 417 | cities2010.selectAll(".city_2010") 418 | .transition() 419 | .style("fill-opacity", 1); 420 | 421 | d3.select("#callOut").style("visibility","hidden"); 422 | 423 | }//showAllDot 424 | 425 | //Show only the circles and line for the hovered over city 426 | function showOneDot(d) { 427 | 428 | //Compare everything with the hovered over city 429 | var chosen = d; 430 | 431 | hoverType = "city"; 432 | 433 | circleHover(chosen); 434 | 435 | cities2010.selectAll(".city_2010") 436 | .transition() 437 | .style("fill-opacity", function(d) { 438 | if (eval("d.rank_" + rVar) != eval("chosen.rank_" + rVar)) return 0.2; 439 | else return 1; 440 | }); 441 | }//showOneDot 442 | 443 | ////////////////////////////////////////////////////// 444 | ////////////////// Y axis locations ////////////////// 445 | ////////////////////////////////////////////////////// 446 | 447 | //Find the locations of the cx for each histogram 448 | function rankLocation(stepSizeVar, Var, minDomain, maxDomain) { 449 | 450 | var rankingArray = []; 451 | 452 | //Stepsize 453 | var stepping = 1/stepSizeVar; 454 | //Keeps track of the height of each year 455 | var perc = d3.range(Math.floor(Math.floor(minDomain*100)/100*stepping)/stepping, 456 | Math.ceil(Math.ceil(maxDomain*100)/100*stepping)/stepping+stepSizeVar, 457 | stepSizeVar).map(function(d,i) { 458 | return { 459 | perc: numFormatTwo(d), 460 | number: 1 461 | }; 462 | }); 463 | 464 | //Save required info in a separate array where the cx position will be filled in later 465 | data.forEach(function(d, i) { 466 | rankingArray.push({ 467 | order: i, 468 | rank: eval("d.rank_" + Var), 469 | growth: eval("d." + Var + "_growth"), 470 | cy: 0 471 | }); 472 | }); 473 | 474 | //Sort by the rank of pop/land/density 475 | rankingArray = rankingArray.sort(compareRank); 476 | //Now in the order of rank, run the locateX function so the smallest ranks (largest) are run first 477 | //and are therefore closer the the axis 478 | for (var i = 0; i < rankingArray.length; i++) { 479 | rankingArray[i].cy = locateY(rankingArray[i].growth, stepping, perc) 480 | }; 481 | //Put the array back in the original order 482 | rankingArray = rankingArray.sort(compareOrder); 483 | 484 | return rankingArray; 485 | }//rankLocation 486 | 487 | function locateY(d, step, perc) { 488 | 489 | //console.log(roundHalf(d, step)); 490 | var percLoc = getByValue(roundHalf(d, step), perc); 491 | 492 | var topping = perc[percLoc].number; 493 | perc[percLoc].number += 1; 494 | 495 | return dotScaleY(topping); 496 | }// function locateX 497 | 498 | //Round to stepSize 499 | function roundHalf(num, step) { 500 | num = numFormatTwo(Math.min(Math.floor(num*step)/step,maxNum)); 501 | return num; 502 | }//roundHalf 503 | 504 | //Get location where perc stays 505 | function getByValue(value, perc) { 506 | for (var i=0, iLen = perc.length; i < iLen; i++) { 507 | if (perc[i].perc == value) return i; 508 | }//for 509 | }//getByValue 510 | 511 | //Order by rank value 512 | function compareRank(a,b) { 513 | if (a.rank < b.rank) 514 | return -1; 515 | if (a.rank > b.rank) 516 | return 1; 517 | return 0; 518 | }//compareRank 519 | 520 | //Order by the order value 521 | function compareOrder(a,b, varname) { 522 | if (a.order < b.order) 523 | return -1; 524 | if (a.order > b.order) 525 | return 1; 526 | return 0; 527 | }//compareOrder 528 | 529 | /* 530 | //Locate the X location based on what has come before 531 | function locateXstraight(d) { 532 | 533 | //console.log(roundHalf(eval("d." + rVar + "_growth"))); 534 | var percLoc = getByValue(roundHalf(eval("d." + rVar + "_growth"))); 535 | 536 | var topping = perc[percLoc].number; 537 | perc[percLoc].number += 1; 538 | 539 | return dotScaleY(topping); 540 | }// function locateX 541 | */ 542 | -------------------------------------------------------------------------------- /js/finalText.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////// Text at the introduction ////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function finalText() { 6 | 7 | modus = "final"; 8 | 9 | //De-activate the continue button 10 | d3.select("#clickerFront").classed("activeButton",false); 11 | d3.select("#clickerFront").classed("inactiveButton",true); 12 | d3.select("#clickerFront").html("Finish"); 13 | 14 | setTimeout(function() {counter = 10;}, 1000); 15 | 16 | ////////////////////////////////////////////////////// 17 | ////////////////// Hide & Remove ///////////////////// 18 | ////////////////////////////////////////////////////// 19 | 20 | //Remove all elements of startBarChart (if present) 21 | startBarChart.selectAll("g").remove(); 22 | 23 | //Set the progress circles 24 | setCircleProgress(9); 25 | 26 | //Reset the progress bar 27 | resetProgressBar(); 28 | 29 | d3.select("#section") 30 | .style("opacity",0) 31 | .style("visibility","hidden"); 32 | 33 | //Remove the bar chart to the right - if present 34 | barChart.selectAll("g") 35 | .transition().duration(1000) 36 | .style("opacity",0) 37 | .call(endall, function() { 38 | barChart.selectAll("g") 39 | .remove(); 40 | }); 41 | barWrappingOther.selectAll("g") 42 | .transition().duration(1000) 43 | .style("opacity",0) 44 | .call(endall, function() { 45 | barWrappingOther.selectAll("g") 46 | .remove(); 47 | }); 48 | 49 | //Hide call-out 50 | d3.select("#callOut").style("visibility","hidden"); 51 | d3.select("#callOutCountryWrapper").style("visibility","hidden"); 52 | 53 | //Hide the buttons - if present 54 | d3.select(".btn-group") 55 | .style("visibility", "hidden"); 56 | 57 | ////////////////////////////////////////////////////// 58 | ///////////////////////// Map //////////////////////// 59 | ////////////////////////////////////////////////////// 60 | 61 | //Increase opacity of the map 62 | map.selectAll(".geo-path") 63 | .attr("visibility", "visible") 64 | .transition().duration(2000) 65 | .style("stroke-opacity", 1) 66 | .style("fill-opacity", 0.5); 67 | 68 | //Start explanation about the World Bank 69 | d3.select("#explanation") 70 | .style("visibility","visible") 71 | .style("top", 175 + "px") 72 | .style("left", 50 + "px") 73 | .style("width", 550 + "px") 74 | .html("

Urbanization is a key process in ending extreme poverty and boosting shared prosperity. In the coming decades, urban areas will be where millions of East Asians will have the chance to leave extreme poverty behind and thrive

" + 75 | "

However, urban expansion, if not well planned, can also exacerbate inequality in access to services, employment, and housing. " + 76 | "It is for this reason we face a rising need to invest in research to define the success factors for well planned urbanisation

" + 77 | "

The choices that are made now may influence the lives of millions in the future: help build the 'new urban society'!

") 78 | .transition().duration(2000).delay(1000) 79 | .style("opacity",1); 80 | 81 | //Show the intro explanation 82 | d3.select("#explanationIntro") 83 | .style("opacity",0) 84 | .style("visibility","visible") 85 | .style("top", 525 + "px") 86 | .style("left", 50 + "px") 87 | .style("width", 550 + "px") 88 | .html("Press the circles that correspond to
map | slope | histogram | scatter
in the bottom to jump back to the intermediary views") 89 | .transition().duration(2000).delay(1000) 90 | .style("opacity",1); 91 | 92 | }//finalText -------------------------------------------------------------------------------- /js/helperFunctions.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////////// Helper Functions ////////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | window.onerror = function() { 6 | location.reload(); 7 | } 8 | 9 | 10 | //Change the explanation text 11 | function explanationText(varText, delay, delayStep) { 12 | d3.select("#explanation") 13 | .transition().duration(1000).delay(delay*delayStep) 14 | .style("opacity",0) 15 | .call(endall, function() { 16 | d3.select("#explanation") 17 | .html(varText); 18 | }) 19 | .transition().duration(1000) 20 | .style("opacity",1); 21 | }//explanationText 22 | 23 | /* 24 | //Deactivate continue and back buttons 25 | function buttonDeactivate(buttonName) { 26 | d3.select(buttonName) 27 | .style("pointer-events", "none") 28 | .transition().duration(400) 29 | .style("border-color", "#D3D3D3") 30 | .style("color", "#D3D3D3"); 31 | }//buttonDeactivate 32 | 33 | //Activate continue and back buttons 34 | function buttonActivate(buttonName, delay) { 35 | d3.select(buttonName) 36 | .style("pointer-events", "auto") 37 | .transition().duration(400).delay(delay) 38 | .style("border-color", "#363636") 39 | .style("color", "#363636"); 40 | }//buttonActivate 41 | */ 42 | 43 | /*Run the progress bar during an animation*/ 44 | function runProgressBar(time) { 45 | 46 | /*Make the progress div visible*/ 47 | d3.selectAll("#progress") 48 | .style("visibility", "visible"); 49 | 50 | /*Linearly increase the width of the bar 51 | //After it is done, hide div again*/ 52 | d3.selectAll(".prgsFront") 53 | .transition().duration(time).ease("linear").delay(100) 54 | .attr("width", prgsWidth) 55 | .call(endall, function() { 56 | d3.selectAll("#progress") 57 | .style("visibility", "hidden"); 58 | /*Reset to zero width*/ 59 | d3.selectAll(".prgsFront") 60 | .attr("width", 0); 61 | }); 62 | 63 | };/*runProgressBar*/ 64 | 65 | /*Reset the progress bar*/ 66 | function resetProgressBar() { 67 | 68 | /*Make the progress div visible*/ 69 | d3.selectAll("#progress") 70 | .style("visibility", "hidden"); 71 | 72 | /*Reset to zero width*/ 73 | d3.selectAll(".prgsFront") 74 | .transition().duration(0) 75 | .attr("width", 0); 76 | 77 | };/*resetProgressBar*/ 78 | 79 | //Set the progress circles white/grey 80 | function setCircleProgress(num) { 81 | for (i = 0; i <= 9; i++) { 82 | if (i <= num) d3.select(eval('"#circle_' + i + '"')).style("background","#D3D3D3"); 83 | if (i > num) d3.select(eval('"#circle_' + i + '"')).style("background","white"); 84 | }//for i 85 | }//setCircleProgress 86 | 87 | //Taken from https://groups.google.com/forum/#!msg/d3-js/WC_7Xi6VV50/j1HK0vIWI-EJ 88 | //Calls a function only after the total transition ends 89 | function endall(transition, callback) { 90 | var n = 0; 91 | transition 92 | .each(function() { ++n; }) 93 | .each("end", function() { if (!--n) callback.apply(this, arguments); }); 94 | } 95 | 96 | /////////////////////////////////////////////////////////////////////////// 97 | /////////////////////////// Mouseover events ////////////////////////////// 98 | /////////////////////////////////////////////////////////////////////////// 99 | 100 | var hoverType; 101 | 102 | //Show city statistics when hovering over circle in map 103 | function circleHover(chosen) { 104 | 105 | //Position of call out depends on view 106 | if (modus == "Dot") { 107 | d3.select("#callOut") 108 | .style("top", "70px") 109 | .style("left", "250px"); 110 | } else { 111 | d3.select("#callOut") 112 | .style("top", "570px") 113 | .style("left", "30px"); 114 | }//else 115 | 116 | //Change the numbers to reflect the hovered over city 117 | if (hoverType == "city") {d3.select("#callOutCity").html(chosen.city + " urban area, " + chosen.country);} 118 | if (hoverType == "country") {d3.select("#callOutCity").html(chosen.country);} 119 | d3.select("#td-pop-2000").html(numFormatTwo(chosen.pop_2000/1e6)); 120 | d3.select("#td-land-2000").html(chosen.land_2000); 121 | d3.select("#td-density-2000").html(Math.round(chosen.density_2000)); 122 | d3.select("#td-pop-2010").html(numFormatTwo(chosen.pop_2010/1e6) + ' (' + chosen.rank_pop + ')'); 123 | d3.select("#td-land-2010").html(chosen.land_2010 + ' (' + chosen.rank_land + ')'); 124 | d3.select("#td-density-2010").html(Math.round(chosen.density_2010) + ' (' + chosen.rank_density + ')'); 125 | d3.select("#td-pop-perc").html(numFormatOne((chosen.pop_2010-chosen.pop_2000)/chosen.pop_2000*100) + "%"); 126 | d3.select("#td-land-perc").html(numFormatOne((chosen.land_2010-chosen.land_2000)/chosen.land_2000*100) + "%"); 127 | d3.select("#td-density-perc").html(numFormatOne((chosen.density_2010-chosen.density_2000)/chosen.density_2000*100) + "%"); 128 | 129 | //Make the callOut visible again 130 | d3.select("#callOut") 131 | .style("visibility","visible"); 132 | 133 | }//circleHover 134 | 135 | //Revert back to default when the mouse moves away from a city 136 | function showAll() { 137 | 138 | if (modus == "Map") { 139 | cities2000.selectAll(".city_2000") 140 | .style("fill-opacity", 0.7); 141 | 142 | cities2010.selectAll(".city_2010") 143 | .style("fill-opacity", 0.5); 144 | } else { 145 | cities2000.selectAll(".city_2000") 146 | .style("fill-opacity", 0.9); 147 | 148 | cities2010.selectAll(".city_2010") 149 | .style("fill-opacity", 0.9); 150 | 151 | }//else 152 | 153 | if (modus == "Slope") { 154 | slopes.selectAll(".slopes") 155 | .style("opacity", 0.4); 156 | 157 | text2000.selectAll("text") 158 | .style("opacity", 0) 159 | .filter(function(d) { return eval("d.rank_" + rVar) < 10;}) 160 | .style("opacity", 0.7); 161 | 162 | text2010.selectAll("text") 163 | .style("opacity", 0) 164 | .filter(function(d) { return eval("d.rank_" + rVar) < 10;}) 165 | .style("opacity", 0.7); 166 | }//if 167 | 168 | //Remove visibility of callout in lower left corner 169 | if (modus == "Map" | modus == "Dot") { 170 | d3.select("#callOut").style("visibility","hidden"); 171 | }//if 172 | 173 | }//slopeAll 174 | 175 | 176 | //Show only the circles and line for the hovered over city 177 | function showOne(d) { 178 | 179 | //Compare everything with the hovered over city 180 | var chosen = d; 181 | var setOpacity = 0; 182 | 183 | //Show information of city in small table in the lower left corner 184 | if (modus == "Map" | modus == "Dot") { 185 | hoverType = "city"; 186 | circleHover(chosen); 187 | setOpacity = 0.1; 188 | }//if 189 | 190 | cities2000.selectAll(".city_2000") 191 | .filter(function(d) {return eval("d.rank_" + rVar) != eval("chosen.rank_" + rVar);}) 192 | .style("fill-opacity", setOpacity); 193 | 194 | cities2010.selectAll(".city_2010") 195 | .filter(function(d) {return eval("d.rank_" + rVar) != eval("chosen.rank_" + rVar);}) 196 | .style("fill-opacity", setOpacity); 197 | 198 | if (modus == "Slope") { 199 | slopes.selectAll(".slopes") 200 | .style("opacity", 0) 201 | .filter(function(d) {return eval("d.rank_" + rVar) == eval("chosen.rank_" + rVar);}) 202 | .style("opacity", 0.4); 203 | 204 | text2000.selectAll("text") 205 | .style("opacity", 0) 206 | .filter(function(d) {return eval("d.rank_" + rVar) == eval("chosen.rank_" + rVar);}) 207 | .style("opacity", 0.7); 208 | 209 | text2010.selectAll("text") 210 | .style("opacity", 0) 211 | .filter(function(d) {return eval("d.rank_" + rVar) == eval("chosen.rank_" + rVar);}) 212 | .style("opacity", 0.7); 213 | }//if 214 | 215 | }//showOne 216 | 217 | //Mouseover event for the bar chart on the right 218 | function highlight(d) { 219 | //Compare everything with the hovered over city 220 | var chosen = d, 221 | setOpacity = 0; 222 | 223 | //Show information of city in small table in the lower left corner 224 | if (modus == "Map" | modus == "Dot") { 225 | hoverType = "country"; 226 | circleHover(chosen); 227 | setOpacity = (modus == "Map" ? 0.1 : 0.2); 228 | }//if 229 | 230 | cities2000.selectAll(".city_2000") 231 | .filter(function(d) {return d.country != chosen.country;}) 232 | .style("fill-opacity", setOpacity); 233 | 234 | cities2010.selectAll(".city_2010") 235 | .filter(function(d) {return d.country != chosen.country;}) 236 | .style("fill-opacity", setOpacity); 237 | 238 | if (modus == "Slope") { 239 | slopes.selectAll(".slopes") 240 | .style("opacity", 0) 241 | .filter(function(d) {return d.country == chosen.country;}) 242 | .style("opacity", 0.4); 243 | 244 | text2000.selectAll("text") 245 | .style("opacity", 0) 246 | .filter(function(d) {return d.country == chosen.country;}) 247 | .style("opacity", 0.7); 248 | 249 | text2010.selectAll("text") 250 | .style("opacity", 0) 251 | .filter(function(d) {return d.country == chosen.country;}) 252 | .style("opacity", 0.7); 253 | }; 254 | 255 | }//highlight -------------------------------------------------------------------------------- /js/introDotHistogram.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////// Introduce Dot Histogram /////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | function introDotHistogram() { 7 | 8 | modus = "Dot"; 9 | firstDot = true; 10 | 11 | setTimeout(function() {counter = 6;}, 1000); 12 | 13 | ////////////////////////////////////////////////////// 14 | ////////////////// Hide & Remove ///////////////////// 15 | ////////////////////////////////////////////////////// 16 | 17 | //Reset the progress bar 18 | resetProgressBar(); 19 | 20 | //Set the progress circles 21 | setCircleProgress(5); 22 | 23 | //Remove the text & button on the right 24 | d3.select("#section") 25 | .style("opacity",0) 26 | .style("visibility","hidden"); 27 | 28 | 29 | //Remove the bar chart to the right - if present 30 | barChart.selectAll("g") 31 | .transition().duration(500) 32 | .style("opacity",0) 33 | .call(endall, function() { 34 | barChart.selectAll("g") 35 | .remove(); 36 | }); 37 | barWrappingOther.selectAll("g") 38 | .transition().duration(500) 39 | .style("opacity",0) 40 | .call(endall, function() { 41 | barWrappingOther.selectAll("g") 42 | .remove(); 43 | }); 44 | 45 | //Remove all slope elements with transition 46 | slopes.selectAll(".slopes") 47 | .transition().duration(500) 48 | .style("opacity", 0) 49 | .call(endall, function() { 50 | slopes.selectAll(".slopes").remove(); 51 | }); 52 | 53 | text2000.selectAll("text") 54 | .transition().duration(500) 55 | .style("opacity", 0) 56 | .call(endall, function() { 57 | text2000.selectAll("text").remove(); 58 | }); 59 | 60 | text2010.selectAll("text") 61 | .transition().duration(500) 62 | .style("opacity", 0) 63 | .call(endall, function() { 64 | text2010.selectAll("text").remove(); 65 | }); 66 | 67 | slopeTitles.selectAll("text") 68 | .transition().duration(500) 69 | .style("opacity", 0) 70 | .call(endall, function() { 71 | slopeTitles.selectAll("text").remove(); 72 | }); 73 | 74 | ////////////////////////////////////////////////////// 75 | ////////////////////// Initialize //////////////////// 76 | ////////////////////////////////////////////////////// 77 | 78 | var delay = 5000; 79 | 80 | //Start the progress bar 81 | runProgressBar(delay*7); 82 | 83 | ////////////////////////////////////////////////////// 84 | //////////////////// Introduction //////////////////// 85 | ////////////////////////////////////////////////////// 86 | 87 | setMouseDot("remove"); 88 | //Create the slopegraph 89 | setTimeout(function () {rVar = "pop"; dotHistogram();}, delay*0.1); 90 | //Deactivate the mouse over events 91 | setTimeout(function() {setMouseDot("remove");}, (delay*0.5)); 92 | 93 | d3.select("#explanation") 94 | .style("visibility","visible") 95 | .transition().duration(1000) 96 | .style("opacity",0) 97 | .call(endall, function() { 98 | d3.select("#explanation") 99 | .style("top", 300 + "px") 100 | .style("left", 600 + "px") 101 | .style("width", 350 + "px") 102 | .html("

Looking at the urban population growth we find that many cities have seen an enormous growth in their population between 2000 and 2010

"); 103 | }) 104 | .transition().duration(1000) 105 | .style("opacity",1); 106 | 107 | 108 | /* 109 | var cityType = d3.scale.ordinal() 110 | .range(["#63A69F","#F2836B","#cb181d"]) 111 | .domain(["Contained","Spillover","Fragmented"]); 112 | cities2010.selectAll(".city_2010") 113 | .style("fill", function(d) {return cityType(d.boundary);}) 114 | .style("fill-opacity", 1); 115 | 116 | var countryType = d3.scale.ordinal() 117 | .range(["#fcbba1","#fb6a4a","#cb181d","#67000d"]) 118 | .domain(["low-income","lower-middle-income","upper-middle-income","high-income"]); 119 | cities2010.selectAll(".city_2010") 120 | .style("fill", function(d) {return countryType(d.type_country);}) 121 | .style("fill-opacity", 1); 122 | */ 123 | 124 | ////////////////////////////////////////////////////// 125 | /////////////////// Density decline ////////////////// 126 | ////////////////////////////////////////////////////// 127 | 128 | explanationText(varText = "

The urban population density has seen both large increase and decline

" + 129 | "

However, 94% of the cities that saw a density decline are in China. This could be caused by the phenomenon of 'Ghost cities' and rising incomes

", 130 | delay = delay, delayStep = 1.75); 131 | setTimeout(function () {rVar = "density"; totalDensityDotHisto();}, delay*1.75); 132 | //Deactivate the mouse over events 133 | setTimeout(function() {setMouseDot("remove");}, (delay*2)); 134 | setTimeout(function () { 135 | cities2010.selectAll(".city_2010") 136 | .on("mouseover", null) 137 | .on("mouseout", null) 138 | .transition().duration(1000) 139 | .style("fill-opacity", function(d) { 140 | if (d.country == "China" & d.density_growth < 0) return 1; 141 | else return 0.2; 142 | }); 143 | }, delay*2.5) 144 | d3.select("#popButton").classed("active",false); 145 | d3.select("#landButton").classed("active",false); 146 | d3.select("#densButton").classed("active",true); 147 | 148 | ////////////////////////////////////////////////////// 149 | ////////////////// Density low income //////////////// 150 | ////////////////////////////////////////////////////// 151 | 152 | explanationText(varText = "Practically the entire area of highest density growth comes from low & low-middle income countries (World Bank 2014) with populations that usually migrate freely", 153 | delay = delay, delayStep = 4); 154 | setTimeout(function () { 155 | cities2010.selectAll(".city_2010") 156 | .transition().duration(1000) 157 | .style("fill-opacity", function(d) { 158 | if (d.type_country == "low-income" | d.type_country == "lower-middle-income") return 1; 159 | else return 0.2; 160 | }); 161 | }, delay*4) 162 | 163 | ////////////////////////////////////////////////////// 164 | ////////////////// Density challenge ///////////////// 165 | ////////////////////////////////////////////////////// 166 | 167 | explanationText(varText = "

Creating the right kind of density and distribution of housing, work locations, transport and parks is a major challenge for these cities

", 168 | delay = delay, delayStep = 5.5); 169 | 170 | ////////////////////////////////////////////////////// 171 | ///////////////////// Finish it ////////////////////// 172 | ////////////////////////////////////////////////////// 173 | 174 | //Make text disappear 175 | d3.select("#explanation") 176 | .transition().duration(1000).delay(delay*7) 177 | .style("opacity",0) 178 | .call(endall, function() { 179 | d3.select("#explanation") 180 | .style("visibility","hidden"); 181 | }); 182 | 183 | setTimeout(function() { 184 | //Set cities back to full opacity 185 | //Resert mouseover event 186 | cities2010.selectAll(".city_2010") 187 | .on("mouseover", showOneDot) 188 | .on("mouseout", showAllDot) 189 | .transition().duration(2000) 190 | .style("fill-opacity", 1); 191 | 192 | //Show the text & button on the right 193 | d3.select("#section") 194 | .transition() 195 | .style("opacity",0) 196 | .call(endall, function() { 197 | d3.select("#section") 198 | .style("visibility","visible"); 199 | 200 | //Change title in top right corner 201 | d3.select("#sectionTitle") 202 | .html("Rapid growth within one decade"); 203 | //Change text in top right corner 204 | d3.select("#sectionText") 205 | .html('

These plots show the rapid growth in land and population within the cities. Growth may lead to numerous economic opportunities. However, it also forces urban policy makers and planners to rethink the design of their cities. The arrangement of future infrastructure can already be a crucial decision. Each city has its own challenges and opportunities and each county its own way of growing

' + 206 | '

Click on the buttons below to see the differences of the urban population, urban land or urban population density per city or hover over the plots to get more detailed information

'); 207 | 208 | }) 209 | .transition().duration(1000) 210 | .style("opacity",1); 211 | 212 | counter = 7; 213 | //Set the progress circles 214 | setCircleProgress(6); 215 | 216 | //Show bar chart again 217 | initiateBarChart(); 218 | }, delay*7); 219 | 220 | 221 | }//function introDotHistogram 222 | 223 | 224 | //Activate or deactivate the mouse events 225 | function setMouseDot(setting) { 226 | 227 | var overSlope = (setting == "remove" ? null : showOneDot); 228 | var outSlope = (setting == "remove" ? null : showAllDot); 229 | 230 | cities2010.selectAll(".city_2010") 231 | .on("mouseover", overSlope) 232 | .on("mouseout", outSlope); 233 | }//setMouseDot -------------------------------------------------------------------------------- /js/introSlope.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | //////////////////////////// Slopegraph Intro ///////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | function introSlope() { 7 | 8 | setTimeout(function() {counter = 4;}, 1000); 9 | 10 | ////////////////////////////////////////////////////// 11 | ////////////////// Hide & Remove ///////////////////// 12 | ////////////////////////////////////////////////////// 13 | 14 | //Reset the progress bar 15 | resetProgressBar(); 16 | 17 | //Set the progress circles 18 | setCircleProgress(3); 19 | 20 | //Remove the text & button on the right 21 | d3.select("#section") 22 | .transition().duration(500) 23 | .style("opacity",0) 24 | .call(endall, function() { 25 | d3.select("#section") 26 | .style("visibility","hidden"); 27 | }); 28 | 29 | //Remove the bar chart to the right - if present 30 | barChart.selectAll("g") 31 | .transition().duration(500) 32 | .style("opacity",0) 33 | .call(endall, function() { 34 | barChart.selectAll("g") 35 | .remove(); 36 | }); 37 | barWrappingOther.selectAll("g") 38 | .transition().duration(500) 39 | .style("opacity",0) 40 | .call(endall, function() { 41 | barWrappingOther.selectAll("g") 42 | .remove(); 43 | }); 44 | 45 | //Remove previous slope elements 46 | slopes.selectAll(".slopes").remove(); 47 | text2000.selectAll("text").remove(); 48 | text2010.selectAll("text").remove(); 49 | slopeTitles.selectAll("text").remove(); 50 | 51 | //Remove color setting from dot-plot 52 | cities2010.selectAll(".city_2010") 53 | .style("fill", null) 54 | .style("fill-opacity", 0.8); 55 | 56 | //Remove dot histogram axis 57 | dotWrapper.selectAll("g").remove(); 58 | dotWrapper.selectAll("text").remove(); 59 | 60 | ////////////////////////////////////////////////////// 61 | ////////////////////// Initialize //////////////////// 62 | ////////////////////////////////////////////////////// 63 | 64 | var delay = 5000; 65 | 66 | //Start the progress bar 67 | runProgressBar(delay*4.75); 68 | 69 | ////////////////////////////////////////////////////// 70 | //////////////////// Introduction //////////////////// 71 | ////////////////////////////////////////////////////// 72 | 73 | //Create the slopegraph 74 | setTimeout(function () {rVar = "pop"; initiateSlopeGraph();}, delay*0.1); 75 | rVar = "pop"; 76 | d3.select("#popButton").classed("active",true); 77 | d3.select("#landButton").classed("active",false); 78 | d3.select("#densButton").classed("active",false); 79 | 80 | d3.select("#explanation") 81 | .style("visibility","visible") 82 | .transition().duration(1000) 83 | .style("opacity",0) 84 | .call(endall, function() { 85 | d3.select("#explanation") 86 | .style("top", 300 + "px") 87 | .style("left", 600 + "px") 88 | .style("width", 350 + "px") 89 | .html("

We can take a closer look at the absolute changes of these cities

Here we see the urban population in 2000 on the left and in 2010 on the right

"); 90 | }) 91 | .transition().duration(1000) 92 | .style("opacity",1); 93 | 94 | //Deactivate the mouse over events 95 | setTimeout(function() {setMouseSlope("remove");}, (delay*0.25)); 96 | 97 | ////////////////////////////////////////////////////// 98 | ///////////////// Pearl River Delta ////////////////// 99 | ////////////////////////////////////////////////////// 100 | explanationText(varText = "Again it becomes apparent how fast the Pearl River Delta has grown during this decade", delay = delay, delayStep = 1.5); 101 | 102 | //Show only one slope 103 | //setTimeout(function() {oneSlope(1, delay);}, (delay*2)); 104 | 105 | ////////////////////////////////////////////////////// 106 | ///////////////// Population Density ///////////////// 107 | ////////////////////////////////////////////////////// 108 | 109 | explanationText(varText = "Or we can look at population density", delay = delay, delayStep =2.3); 110 | 111 | //Change to a density slopegraph 112 | setTimeout(totalDensitySlopeGraph, delay*2.4); 113 | //Deactivate the mouse over events 114 | setTimeout(function() { 115 | setMouseSlope("remove"); 116 | 117 | totalDensityBarGraph(); 118 | d3.select("#popButton").classed("active",false); 119 | d3.select("#densButton").classed("active",true); 120 | 121 | }, (delay*2.4)); 122 | 123 | ////////////////////////////////////////////////////// 124 | ////////////////////// Indonesia ///////////////////// 125 | ////////////////////////////////////////////////////// 126 | 127 | //explanationText(varText = "Practically all cities in Indonesia saw an increase in their average urban population density", delay = delay, delayStep = 3.5); 128 | setTimeout(function() {oneCountrySlope("Indonesia", delay)},(delay*3.25)) 129 | explanationText(varText = "

Urban population density in Indonesia jumped from 7400 people per sq. km in 2000 to 9400 in 2010, an increase of almost 30%!

" + 130 | "

This is most likely due to constraints in investment in urban infrastructure and housing

", 131 | delay = delay, delayStep = 2.75); 132 | 133 | ////////////////////////////////////////////////////// 134 | /////////////// How many down and up ///////////////// 135 | ////////////////////////////////////////////////////// 136 | 137 | ////////////////////////////////////////////////////// 138 | ///////////////////// Finish it ////////////////////// 139 | ////////////////////////////////////////////////////// 140 | 141 | //Make text disappear 142 | d3.select("#explanation") 143 | .transition().duration(1000).delay(delay*4.75) 144 | .style("opacity",0) 145 | .call(endall, function() { 146 | d3.select("#explanation") 147 | .style("visibility","hidden"); 148 | }); 149 | 150 | 151 | //Show the text & button on the right 152 | /* 153 | d3.select("#section") 154 | .transition().delay(delay*4.75) 155 | .style("opacity",0) 156 | .call(endall, function() { 157 | d3.select("#section") 158 | .style("visibility","visible"); 159 | }) 160 | .transition().duration(1500) 161 | .style("opacity",1); 162 | */ 163 | 164 | //Show the text & button on the right 165 | d3.select("#section") 166 | .transition().delay(delay*4.75) 167 | .style("opacity",0) 168 | .call(endall, function() { 169 | d3.select("#section") 170 | .style("visibility","visible"); 171 | //Change title in top right corner 172 | d3.select("#sectionTitle") 173 | .style("opacity",1) 174 | .html("Creating the right kind of density in a city"); 175 | //Change text in top right corner 176 | d3.select("#sectionText") 177 | .html('

Urban population density, which was already high in the year 2000 for East Asia has only grown larger for practically all cities outside of China. Continuous growth can be expected in the coming years. Therefore, the focus for urban planners should be on the design of this density, the appropriate coordination and location of different city aspects

' + 178 | '

Click on the buttons below to see the differences of the urban population, urban land or urban population density per city or hover over the plots to get more detailed information

'); 179 | }) 180 | .transition().duration(1000) 181 | .style("opacity",1); 182 | 183 | setTimeout(function() { 184 | counter = 5; 185 | //Set the progress circles 186 | setCircleProgress(4); 187 | //Set mouse over again 188 | setMouseSlope("initiate"); 189 | //Draw full slopegraph again 190 | totalDensitySlopeGraph(); 191 | //Show bar chart again 192 | initiateBarChart(); 193 | }, delay*4.8); 194 | 195 | 196 | }//introSlope 197 | 198 | //Activate or deactivate the mouse events 199 | function setMouseSlope(setting) { 200 | 201 | var overSlope = (setting == "remove" ? null : showOne); 202 | var outSlope = (setting == "remove" ? null : showAll); 203 | 204 | cities2000.selectAll(".city_2000") 205 | .on("mouseover", overSlope) 206 | .on("mouseout", outSlope); 207 | 208 | cities2010.selectAll(".city_2010") 209 | .on("mouseover", overSlope) 210 | .on("mouseout", outSlope); 211 | 212 | slopes.selectAll(".slopes") 213 | .on("mouseover", overSlope) 214 | .on("mouseout", outSlope); 215 | 216 | text2000.selectAll("text") 217 | .on("mouseover", overSlope) 218 | .on("mouseout", outSlope); 219 | 220 | text2010.selectAll("text") 221 | .on("mouseover", overSlope) 222 | .on("mouseout", outSlope); 223 | }//setMouseSlope 224 | 225 | function oneSlope(rank, delay) { 226 | //Show only one slope 227 | cities2000.selectAll(".city_2000") 228 | .transition().duration(1000) 229 | .style("fill-opacity", function(d) { 230 | if (d.rank_pop != rank) return 0;}); 231 | 232 | cities2010.selectAll(".city_2010") 233 | .transition().duration(1000) 234 | .style("fill-opacity", function(d) { 235 | if (d.rank_pop != rank) return 0;}); 236 | 237 | slopes.selectAll(".slopes") 238 | .transition().duration(1000) 239 | .style("opacity", function(d) { 240 | if (d.rank_pop != rank) return 0; 241 | else return 0.4}); 242 | 243 | text2000.selectAll("text") 244 | .transition().duration(1000) 245 | .style("opacity", function(d) { 246 | if (d.rank_pop != rank) return 0; 247 | else return 0.7;}); 248 | 249 | text2010.selectAll("text") 250 | .transition().duration(1000) 251 | .style("opacity", function(d) { 252 | if (d.rank_pop != rank) return 0; 253 | else return 0.7;}); 254 | 255 | //Show all slopes again 256 | cities2000.selectAll(".city_2000") 257 | .transition().duration(1000).delay(delay*1.25) 258 | .style("fill-opacity", 0.8); 259 | 260 | cities2010.selectAll(".city_2010") 261 | .transition().duration(1000).delay(delay*1.25) 262 | .style("fill-opacity", 0.8); 263 | 264 | slopes.selectAll(".slopes") 265 | .transition().duration(1000).delay(delay*1.25) 266 | .style("opacity", 0.4); 267 | 268 | text2000.selectAll("text") 269 | .transition().duration(1000).delay(delay*1.25) 270 | .style("opacity", function(d) { 271 | if (d.rank_pop <= 10) return 0.7; 272 | else return 0;}); 273 | 274 | text2010.selectAll("text") 275 | .transition().duration(1000).delay(delay*1.25) 276 | .style("opacity", function(d) { 277 | if (d.rank_pop <= 10) return 0.7; 278 | else return 0;}); 279 | 280 | }//oneSlope 281 | 282 | function oneCountrySlope(country, delay) { 283 | //Show one specific country 284 | cities2000.selectAll(".city_2000") 285 | .transition().duration(1000) 286 | .style("fill-opacity", function(d) { 287 | if (d.country != country) return 0;}); 288 | 289 | cities2010.selectAll(".city_2010") 290 | .transition().duration(1000) 291 | .style("fill-opacity", function(d) { 292 | if (d.country != country) return 0;}); 293 | 294 | slopes.selectAll(".slopes") 295 | .transition().duration(1000) 296 | .style("opacity", function(d) { 297 | if (d.country != country) return 0; 298 | else return 0.4;}); 299 | 300 | text2000.selectAll("text") 301 | .transition().duration(1000) 302 | .style("opacity", function(d) { 303 | if (d.country != country) return 0; 304 | else return 0.7;}); 305 | 306 | text2010.selectAll("text") 307 | .transition().duration(1000) 308 | .style("opacity", function(d) { 309 | if (d.country != country) return 0; 310 | else return 0.7;}); 311 | 312 | }//oneCountrySlope -------------------------------------------------------------------------------- /js/introText.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////// Text at the introduction ////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function introText() { 6 | 7 | modus = "intro"; 8 | 9 | //De-activate the back button 10 | d3.select("#clickerBack").classed("inactiveButton",true); 11 | d3.select("#clickerBack").classed("activeButton",false); 12 | //Change text of front button 13 | d3.select("#clickerFront").html("Start"); 14 | 15 | setTimeout(function() {counter = 1;}, 1000); 16 | 17 | ////////////////////////////////////////////////////// 18 | ////////////////// Hide & Remove ///////////////////// 19 | ////////////////////////////////////////////////////// 20 | 21 | //Remove all elements of startBarChart (if present) 22 | startBarChart.selectAll("g").remove(); 23 | 24 | //Set the progress circles 25 | setCircleProgress(0); 26 | 27 | //Reset the progress bar 28 | resetProgressBar(); 29 | 30 | d3.select("#section") 31 | .style("opacity",0) 32 | .style("visibility","hidden"); 33 | 34 | //Remove the bar chart to the right - if present 35 | barChart.selectAll("g").remove(); 36 | barWrappingOther.selectAll("g").remove(); 37 | 38 | //Hide call-out 39 | d3.select("#callOut").style("visibility","hidden"); 40 | 41 | //Hide the cities - if present 42 | cities2010.selectAll(".city_2010") 43 | .on("mouseover", null) 44 | .on("mouseout", null) 45 | .transition().duration(1000) 46 | .attr("r", 0) 47 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 48 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 49 | cities2000.selectAll(".city_2000") 50 | .on("mouseover", null) 51 | .on("mouseout", null) 52 | .transition().duration(1000) 53 | .attr("r", 0) 54 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 55 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 56 | 57 | //Hide the buttons - if present 58 | d3.select(".btn-group") 59 | .style("visibility", "hidden"); 60 | 61 | ////////////////////////////////////////////////////// 62 | ///////////////////////// Map //////////////////////// 63 | ////////////////////////////////////////////////////// 64 | 65 | //Increase opacity of the map 66 | map.selectAll(".geo-path") 67 | .attr("visibility", "visible") 68 | .transition().duration(2000) 69 | .style("stroke-opacity", 1) 70 | .style("fill-opacity", 0.5); 71 | 72 | //Start explanation about the World Bank 73 | d3.select("#explanation") 74 | .style("visibility","visible") 75 | .style("top", 200 + "px") 76 | .style("left", 50 + "px") 77 | .style("width", 550 + "px") 78 | .html("

Societies are shifting from having a rural nature to a more and more urban nature. We face the opportunity to set the course of urbanization on a more sustainable and equitable path

" + 79 | "

This visualization is based on data on urbanization in East Asia between 2000 and 2010 collected by the World Bank using Satellite images and population models. It aims to provide you with a clear view on the magnitude of changes that can happen in only one decade and challenges you to think about the impact on the following years

") 80 | .transition().duration(1000) 81 | .style("opacity",1); 82 | 83 | //Show the intro explanation 84 | d3.select("#explanationIntro") 85 | d3.select("#explanationIntro") 86 | .style("visibility","visible") 87 | .style("top", 475 + "px") 88 | .style("left", 50 + "px") 89 | .style("width", 550 + "px") 90 | .html("Press Start to be taken through the complete story, or press the circles that correspond to
map | slope | histogram | scatter
to jump straight to the intermediary views") 91 | .style("opacity",1); 92 | 93 | }//introText -------------------------------------------------------------------------------- /js/introUrbanScatter.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////////// Bar Chart to Scatter ////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function introUrbanScatter() { 6 | 7 | //Change visual modus 8 | modus = "urbanPopDot"; 9 | 10 | setTimeout(function() {counter = 8;}, 1000); 11 | 12 | //Set the progress circles 13 | setCircleProgress(7); 14 | 15 | ////////////////////////////////////////////////////// 16 | ////////////////// Hide & Remove ///////////////////// 17 | ////////////////////////////////////////////////////// 18 | 19 | //Reset the progress bar 20 | resetProgressBar(); 21 | 22 | //Remove the two bars - if present 23 | startBarChart.selectAll("g").remove(); 24 | 25 | //Hide call-out 26 | d3.select("#callOut").style("visibility","hidden"); 27 | 28 | //Remove previous slope elements 29 | slopes.selectAll(".slopes").remove(); 30 | text2000.selectAll("text").remove(); 31 | text2010.selectAll("text").remove(); 32 | slopeTitles.selectAll("text").remove(); 33 | 34 | //Hide the buttons 35 | d3.select(".btn-group") 36 | .style("visibility", "hidden"); 37 | 38 | //Remove the intro explanation 39 | d3.select("#explanationIntro") 40 | .transition().duration(1000) 41 | .style("opacity",0) 42 | .call(endall, function() { 43 | d3.select("#explanationIntro") 44 | .style("visibility","hidden"); 45 | }); 46 | 47 | //Make text & call-out disappear - if present 48 | d3.select("#explanation") 49 | .transition().duration(1000) 50 | .style("opacity",0) 51 | .call(endall, function() { 52 | d3.select("#explanation") 53 | .style("visibility","hidden"); 54 | }); 55 | 56 | //Remove map - if present 57 | map.selectAll(".geo-path") 58 | .transition().duration(2000) 59 | .style("stroke-opacity", 0) 60 | .style("fill-opacity", 0) 61 | .call(endall, function() { 62 | map.selectAll(".geo-path") 63 | .attr("visibility", "hidden"); 64 | }); 65 | 66 | //Remove the text & button on the right 67 | d3.select("#section") 68 | .transition().duration(500) 69 | .style("opacity",0) 70 | .call(endall, function() { 71 | d3.select("#section") 72 | .style("visibility","hidden"); 73 | }); 74 | 75 | //Remove dot histogram axis & text 76 | dotWrapper.selectAll("g") 77 | .transition().duration(1000) 78 | .style("opacity", 0) 79 | .remove(); 80 | dotWrapper.selectAll("text") 81 | .transition().duration(1000) 82 | .style("opacity", 0) 83 | .remove(); 84 | 85 | //Remove 2000 cities 86 | cities2000.selectAll(".city_2000") 87 | .transition().duration(1000) 88 | .attr("r", 0) 89 | .style("fill-opacity", 0); 90 | 91 | //Remove 2010 cities 92 | cities2010.selectAll(".city_2010") 93 | .style("fill", null) 94 | .transition().duration(1000) 95 | .attr("r", 0) 96 | .style("fill-opacity", 0); 97 | 98 | //Show bar chart again 99 | initiateBarChart(); 100 | ////////////////////////////////////////////////////// 101 | ////////////////////// Initialize //////////////////// 102 | ////////////////////////////////////////////////////// 103 | 104 | var delay = 5000; 105 | 106 | //Start the progress bar 107 | runProgressBar(delay*7); 108 | 109 | //New height of each country section 110 | newBarHeight = (barDimHeight/countries.length); 111 | 112 | //Set the new x axis range 113 | barScale 114 | .range([0, barDimWidth]); 115 | xAxis.scale(barScale); 116 | //Set the new y axis range 117 | yBarScale 118 | .range([barDimHeight,100]) 119 | .domain([0, 70000]); 120 | yAxis 121 | .tickFormat(numFormatCurrency) 122 | .scale(yBarScale); 123 | 124 | ////////////////////////////////////////////////////// 125 | ////////// Move to left and make bigger ////////////// 126 | ////////////////////////////////////////////////////// 127 | 128 | d3.select("#explanation") 129 | .style("visibility","visible") 130 | .transition().duration(1000) 131 | .style("opacity",0) 132 | .call(endall, function() { 133 | d3.select("#explanation") 134 | .style("top", 260 + "px") 135 | .style("left", 590 + "px") 136 | .style("width", 380 + "px") 137 | .html("Finally, let's zoom into the countries and look at what the future might hold"); 138 | }) 139 | .transition().duration(1000).delay(2000) 140 | .style("opacity",1); 141 | 142 | //Move bar chart to the new location 143 | barChart 144 | .style("visibility","visible") 145 | .transition().duration(2000) 146 | .style("opacity",1) 147 | .attr("width", barDimWidth) 148 | .attr("height", barDimHeight) 149 | .attr("transform","translate(" + barX + "," + barY + ")"); 150 | //Move the axes wrapper 151 | barWrappingOther 152 | .style("visibility","visible") 153 | .transition().duration(2000) 154 | .style("opacity",1) 155 | .attr("width", barDimWidth) 156 | .attr("height", 20) 157 | .attr("transform","translate(" + barX + ", " + (barY + barDimHeight) +")"); 158 | 159 | //Move and update the bar title 160 | barChart.selectAll(".barTitle") 161 | .style("font-size", "18px") 162 | .style("opacity",0) 163 | .transition().duration(1000) 164 | .attr("transform", "translate(" + ((barX+75) + (barDimWidth-(barX+75))/2) + "," + -15 + ")"); 165 | 166 | //Create more room between the bars 167 | barChart.selectAll(".barWrapper") 168 | .on("mouseover", null) 169 | .on("mouseout", null) 170 | .transition().duration(2000).delay(2000) 171 | .attr("transform", function(d, i) { return "translate(75," + (5 + (eval("d.rank_" + rVar + "-1")) * newBarHeight) + ")"; }); 172 | 173 | //Update the 2010 bar widths 174 | barChart.selectAll(".city_2010") 175 | .transition().duration(2000).delay(2000) 176 | .attr("width", function(d) {return barScale(eval("d." + rVar + "_2010"));}); 177 | 178 | //Update the 2000 bar widths 179 | barChart.selectAll(".city_2000") 180 | .transition().duration(2000).delay(2000) 181 | .attr("width", function(d) {return barScale(eval("d." + rVar + "_2000"));}); 182 | 183 | //Update the x axis 184 | barWrappingOther.select(".x.axis") 185 | .transition().duration(2000).delay(2000) 186 | .call(xAxis); 187 | 188 | ////////////////////////////////////////////////////// 189 | /////////// Change to urban population % ///////////// 190 | ////////////////////////////////////////////////////// 191 | 192 | setTimeout(function() { 193 | 194 | explanationText(varText = "Here we see the % of the total population that lives in urban areas with more than 100,000 people", 195 | delay = delay, delayStep = 0); 196 | 197 | //Set the new x-axis domain 198 | barScale.domain([0,0.7]); 199 | //Set new x-axis 200 | xAxis 201 | .ticks(8) 202 | .scale(barScale) 203 | .tickFormat(numFormatPercent); 204 | //Update the x axis 205 | barWrappingOther.selectAll(".x.axis") 206 | .transition().duration(1000) 207 | .call(xAxis); 208 | barWrappingOther.selectAll(".x.axis text") 209 | .style("font-size", "10px"); 210 | //Set up X axis label 211 | barWrappingOther.append("g") 212 | .append("text") 213 | .attr("class", "x label titleTop") 214 | .attr("text-anchor", "middle") 215 | .attr("transform", "translate(" + (75 + barDimWidth/2) + "," + 60 + ")") 216 | .style("font-size", "15px") 217 | .style("opacity", 0) 218 | .text("% of population living in urban areas of 100,000 people or more") 219 | .transition().duration(1000) 220 | .style("opacity", 1); 221 | 222 | //Remove background 223 | barChart.selectAll(".background").remove(); 224 | 225 | barChart.selectAll(".barWrapper") 226 | .filter(function(d) {return d.country == "Singapore";}) 227 | .transition().duration(1000) 228 | .style("opacity", 0) 229 | .remove(); 230 | 231 | //Make dots of the 2000 bars 232 | barChart.selectAll(".city_2000") 233 | .transition().duration(1000) 234 | .style("fill-opacity", 1) 235 | .attr("rx",dotSize) 236 | .attr("ry",dotSize) 237 | .attr("width",dotSize) 238 | .attr("height",dotSize) 239 | .attr("transform", function (d) { 240 | return "translate(" + (barScale(d.pop_perc_2000) - dotSize/2) + "," + (barHeight/2 - dotSize/2) + ")"; 241 | }); 242 | 243 | //Make dots of the 2010 bars 244 | barChart.selectAll(".city_2010") 245 | .transition().duration(1000) 246 | .style("fill-opacity", 1) 247 | .attr("rx",dotSize) 248 | .attr("ry",dotSize) 249 | .attr("width",dotSize) 250 | .attr("height",dotSize) 251 | .attr("transform", function (d) { 252 | return "translate(" + (barScale(d.pop_perc_2010) - dotSize/2) + "," + (barHeight/2 - dotSize/2) + ")"; 253 | }); 254 | 255 | //Create the lines between the 2000 and 2010 dots 256 | barChart.selectAll("line") 257 | .attr("x1", function(d) {return barScale(d.pop_perc_2000);}) 258 | .attr("x2", function(d) {return barScale(d.pop_perc_2010);}) 259 | .attr("y1", (barHeight/2)) 260 | .attr("y2", (barHeight/2)) 261 | .transition().duration(1000).delay(1000) 262 | .style("opacity", 1); 263 | 264 | //Create 50% line 265 | barWrappingOther.append("g") 266 | .append("line") 267 | .attr("class", "halfway-line") 268 | .attr("x1", (75+barScale(0.5))) 269 | .attr("x2", (75+barScale(0.5))) 270 | .attr("y1", 0) 271 | .attr("y2", (-barDimHeight + 20)) 272 | .style("stroke-width", 1) 273 | .style("stroke","#AAAAAA") 274 | .style("stroke-dasharray", ("7, 4")) 275 | .style("opacity", 0); 276 | 277 | //Reshuffle in order of population % 278 | barChart.selectAll(".barWrapper") 279 | .style("visibility","visible") 280 | .transition().duration(1000).delay(2000) 281 | .attr("transform", function(d, i) { return "translate(75," + (5 + (d.rank_pop_perc - 1) * newBarHeight) + ")"; }) 282 | 283 | //More urban growth expected 284 | explanationText(varText = "

Even with the enormous shift of 200 million people moving towards cities within one decade, most countries still have far less than 50% of their total population living in a city

" + 285 | "

Therefore, it is likely to assume that the next decades will see continuous urban growth

", 286 | delay = delay, delayStep = 1); 287 | 288 | //Show 50% line 289 | barWrappingOther.select(".halfway-line") 290 | .transition().duration(1000).delay(delay) 291 | .style("opacity", 1); 292 | 293 | }, delay*1); 294 | 295 | 296 | ////////////////////////////////////////////////////// 297 | /////////////////// Change to GDP //////////////////// 298 | ////////////////////////////////////////////////////// 299 | setTimeout(function() { 300 | 301 | explanationText(varText = "

If combined with the change in income per capita, the relationship between urban and economic growth becomes visible

", 302 | delay = delay, delayStep = 0); 303 | 304 | explanationText(varText = "

While most countries have seen a more free migration towards cities, their GDP has grown between 2000 and 2010.

" + 305 | "

One can only speculate about the possible economic growth if sustainable urbanization is understood and carefully planned

", 306 | delay = delay, delayStep = 1); 307 | 308 | //Remove the y-axis labels 309 | barChart.selectAll(".barLabels") 310 | .transition().duration(1000) 311 | .style("opacity", 0) 312 | .remove(); 313 | 314 | //Remove 50% line 315 | barWrappingOther.select(".halfway-line") 316 | .transition().duration(1000) 317 | .style("opacity", 0) 318 | .remove(); 319 | 320 | //Remove all countries with unknown GDP 321 | barChart.selectAll(".barWrapper") 322 | .filter(function(d) {return d.gdp_2000 == 0;}) 323 | .transition().duration(1000) 324 | .style("opacity", 0) 325 | .remove(); 326 | 327 | //Remove the y-component of the barWrapper transform 328 | barChart.selectAll(".barWrapper") 329 | .transition().duration(1000).delay(1000) 330 | .attr("transform", "translate(75,0)"); 331 | 332 | counter = 9; 333 | //Set the progress circles 334 | setCircleProgress(8); 335 | 336 | setTimeout(createScatter, 1000); 337 | 338 | ////////////////////////////////////////////////////// 339 | ///////////////////// Finish it ////////////////////// 340 | ////////////////////////////////////////////////////// 341 | 342 | //Make text disappear 343 | d3.select("#explanation") 344 | .transition().duration(1000).delay(delay*3) 345 | .style("opacity",0) 346 | .call(endall, function() { 347 | d3.select("#explanation") 348 | .style("visibility","hidden"); 349 | }); 350 | 351 | //Show the text & button on the right 352 | d3.select("#section") 353 | .transition().delay(delay*3) 354 | .style("opacity",0) 355 | .call(endall, function() { 356 | d3.select("#section") 357 | .style("visibility","visible"); 358 | 359 | //Change title in top right corner 360 | d3.select("#sectionTitle") 361 | .html("Urbanization and economic prosperity"); 362 | //Change text in top right corner 363 | d3.select("#sectionText") 364 | .html('

Even though it would almost appear as if all inhabitants of East Asia live in cities, the large majority of the citizens currently still live in rural areas. Continuous urban growth is therefore expected to occur in the coming decades

' + 365 | '

The current view reveals a correlation between a rise in the urban population as a percentage to the whole population and an increase in the GDP (for the countries where GDP information is available) showing a glance of the possible economic prosperity that continuous urban growth might bring to an urban area and people that might move here in the coming future

' + 366 | '

For now, one can only speculate about the impact the continuous move towards cities will have on the social and economic circumstances of these families and areas. However, with more investment into research on the factors that influence the positive side of urbanization a future might be created in which more urban areas can be a place of constant development and continuous economic and social opportunities

' + 367 | '

To see which country belongs to each circle-line element hover over the plot on the left

'); 368 | }) 369 | .transition().duration(1000) 370 | .style("opacity",1); 371 | 372 | }, delay*4); 373 | 374 | 375 | 376 | }//introUrbanScatter -------------------------------------------------------------------------------- /js/introduceCities.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | //////////////////////////// Introduce cities ///////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function introduceCities() { 6 | 7 | modus = "introduceCities"; 8 | hoverType = "city"; 9 | rVar == "pop"; 10 | 11 | //setTimeout(function() {counter = 3;}, 1000); 12 | 13 | ////////////////////////////////////////////////////// 14 | ////////////////// Hide & Remove ///////////////////// 15 | ////////////////////////////////////////////////////// 16 | 17 | //Reset the progress bar 18 | //resetProgressBar(); 19 | 20 | //Set the progress circles 21 | //setCircleProgress(2); 22 | 23 | //d3.select("#section") 24 | // .style("opacity",0) 25 | // .style("visibility","hidden"); 26 | 27 | //Remove the two bars - if present 28 | startBarChart.selectAll("g") 29 | .transition().duration(1000) 30 | .style("opacity",0) 31 | .call(endall, function() { 32 | startBarChart.selectAll("g") 33 | .remove(); 34 | }); 35 | 36 | //Remove the bar chart to the right - if present 37 | //barChart.selectAll("g").remove(); 38 | //barWrappingOther.selectAll("g").remove(); 39 | 40 | //Hide the cities - if present 41 | cities2010.selectAll(".city_2010") 42 | .on("mouseover", null) 43 | .on("mouseout", null) 44 | .transition().duration(1000) 45 | .attr("r", 0) 46 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 47 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 48 | cities2000.selectAll(".city_2000") 49 | .on("mouseover", null) 50 | .on("mouseout", null) 51 | .transition().duration(1000) 52 | .attr("r", 1.5) 53 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 54 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 55 | 56 | //Remove dot histogram axis 57 | //dotWrapper.selectAll("g").remove(); 58 | //dotWrapper.selectAll("text").remove(); 59 | 60 | ////////////////////////////////////////////////////// 61 | ////////////////////// Initialize //////////////////// 62 | ////////////////////////////////////////////////////// 63 | 64 | var delay = 5000; 65 | 66 | //Start the progress bar 67 | //runProgressBar(delay*5.25); 68 | 69 | rScale 70 | .domain([d3.min(data, function(d) {return d.pop_2000;}),d3.max(data, function(d) {return d.pop_2010;})]) 71 | .range([1,20]); 72 | 73 | //Increase opacity of the map 74 | map.selectAll(".geo-path") 75 | .attr("visibility", "visible") 76 | .transition().duration(1000).delay(500) 77 | .style("stroke-opacity", 1) 78 | .style("fill-opacity", 1); 79 | 80 | ////////////////////////////////////////////////////// 81 | /////////////////// Smallest cities ////////////////// 82 | ////////////////////////////////////////////////////// 83 | //Smallest cities 84 | d3.select("#explanation") 85 | .style("visibility","visible") 86 | .transition().duration(1000) 87 | .style("opacity",0) 88 | .call(endall, function() { 89 | d3.select("#explanation") 90 | .style("top", 350 + "px") 91 | .style("left", 400 + "px") 92 | .style("width", 400 + "px") 93 | .html("There are 738 cities with a population between 100,000 to 1 million people"); 94 | }) 95 | .transition().duration(1000) 96 | .style("opacity",1); 97 | 98 | //Highlight the small cities - 2000 99 | cities2010.selectAll(".city_2010") 100 | .filter(function(d) { return d.pop_2010 < 1e6;}) 101 | .transition().duration(2000).delay(1000) 102 | .attr("r", function(d) {return rScale(d.pop_2010);}) 103 | .style("fill-opacity", 1) 104 | .transition().duration(1500) 105 | .style("fill-opacity", 0.5); 106 | 107 | //Highlight the small cities - 2010 108 | cities2000.selectAll(".city_2000") 109 | .filter(function(d) { return d.pop_2010 < 1e6;}) 110 | .transition().duration(2000).delay(1000) 111 | .attr("r", function(d) {return rScale(d.pop_2000);}) 112 | .style("fill-opacity", 1) 113 | .transition().duration(1500) 114 | .style("fill-opacity", 0.7); 115 | 116 | ////////////////////////////////////////////////////// 117 | //////////////////// Medium cities /////////////////// 118 | ////////////////////////////////////////////////////// 119 | //Medium cities 120 | explanationText(varText = "123 cities with a population between 1 and 10 million people", delay = delay, delayStep = 1); 121 | 122 | //Plot the sizes of the cities in 2010 in reddish 123 | cities2010.selectAll(".city_2010") 124 | .filter(function(d) { return d.pop_2010 >= 1e6 & d.pop_2010 < 10e6;}) 125 | .transition().duration(2000).delay(1*delay) 126 | .attr("r", function(d) {return rScale(d.pop_2010);}) 127 | .style("fill-opacity", 1) 128 | .transition().duration(1500) 129 | .style("fill-opacity", 0.5); 130 | 131 | //On the same location plot the sizes of the cities in 2000 in greyish 132 | cities2000.selectAll(".city_2000") 133 | .filter(function(d) { return d.pop_2010 >= 1e6 & d.pop_2010 < 10e6;}) 134 | .transition().duration(2000).delay(1*delay) 135 | .attr("r", function(d) {return rScale(d.pop_2000);}) 136 | .style("fill-opacity", 1) 137 | .transition().duration(1500) 138 | .style("fill-opacity", 0.7); 139 | 140 | ////////////////////////////////////////////////////// 141 | //////////////////// Large cities //////////////////// 142 | ////////////////////////////////////////////////////// 143 | //Large cities 144 | explanationText(varText = "And 8 megacities with more than 10 million people", delay = delay, delayStep = 2); 145 | 146 | //Plot the sizes of the cities in 2010 in reddish 147 | cities2010.selectAll(".city_2010") 148 | .filter(function(d) { return d.pop_2010 >= 10e6;}) 149 | .transition().duration(2000).delay(2*delay) 150 | .attr("r", function(d) {return rScale(d.pop_2010);}) 151 | .style("fill-opacity", 1) 152 | .transition().duration(1500) 153 | .style("fill-opacity", 0.5); 154 | 155 | //On the same location plot the sizes of the cities in 2000 in greyish 156 | cities2000.selectAll(".city_2000") 157 | .filter(function(d) { return d.pop_2010 >= 10e6;}) 158 | .transition().duration(2000).delay(2*delay) 159 | .attr("r", function(d) {return rScale(d.pop_2000);}) 160 | .style("fill-opacity", 1) 161 | .transition().duration(1500) 162 | .style("fill-opacity", 0.7); 163 | 164 | ////////////////////////////////////////////////////// 165 | ///////////////// Pearl River Delta ////////////////// 166 | ////////////////////////////////////////////////////// 167 | //Pearl River Delta 168 | explanationText(varText = "For example, the Pearl River Delta in China has overtaken Tokyo as the world’s largest urban area in both size and population", delay = delay, delayStep = 3); 169 | 170 | cities2000.selectAll(".city_2000") 171 | .transition().duration(2000).delay(3*delay) 172 | .style("fill-opacity", function(d) { 173 | if(d.rank_pop == 1) {return 0.9;} 174 | else {return 0.05;} 175 | }); 176 | cities2010.selectAll(".city_2010") 177 | .transition().duration(2000).delay(3*delay) 178 | .style("fill-opacity", function(d) { 179 | if(d.rank_pop == 1) {return 0.9;} 180 | else {return 0.05;} 181 | }); 182 | setTimeout(function() {circleHover($.grep(data, function(d) {return d.rank_pop == 1;})[0])}, 3.25*delay); 183 | 184 | explanationText(varText = "Its population grew with more than 50% to almost 42 million people", delay = delay, delayStep = 4.25); 185 | 186 | /* 187 | cities2000.selectAll(".city_2000") 188 | .transition().duration(2000).delay(5.75*delay) 189 | .style("fill-opacity", 0.05); 190 | cities2010.selectAll(".city_2010") 191 | .transition().duration(2000).delay(5.75*delay) 192 | .style("fill-opacity", 0.05); 193 | */ 194 | ////////////////////////////////////////////////////// 195 | ///////////////////// Zhumadian ////////////////////// 196 | ////////////////////////////////////////////////////// 197 | /*//Zhumadian 198 | explanationText(varText = "The Zhumadian urban area, though relatively small, has seen a population growth of almost 150%", delay = delay, delayStep = 6); 199 | 200 | cities2000.selectAll(".city_2000") 201 | .transition().duration(2000).delay(6*delay) 202 | .style("fill-opacity", function(d) { 203 | if(d.rank_pop == 320) {return 1;} 204 | else {return 0.025;} 205 | }); 206 | cities2010.selectAll(".city_2010") 207 | .transition().duration(2000).delay(6*delay) 208 | .style("fill-opacity", function(d) { 209 | if(d.rank_pop == 320) {return 1;} 210 | else {return 0.025;} 211 | }); 212 | setTimeout(function() {circleHover($.grep(data, function(d) {return d.rank_pop == 320;})[0])}, 6.25*delay); 213 | 214 | explanationText(varText = "However, the population density increased steeply, with 85% because the urban land increased much slower", delay = delay, delayStep = 7.75); 215 | */ 216 | ////////////////////////////////////////////////////// 217 | ///////////////////// Finish it ////////////////////// 218 | ////////////////////////////////////////////////////// 219 | //Make text disappear 220 | d3.select("#explanation") 221 | .transition().duration(1000).delay(delay*5.25) 222 | .style("opacity",0) 223 | .call(endall, function() { 224 | d3.select("#explanation") 225 | .style("visibility","hidden"); 226 | 227 | d3.select("#callOut").style("visibility","hidden"); 228 | }); 229 | 230 | 231 | setTimeout(totalAreaMap, delay*5.25); 232 | 233 | }//introduceCities -------------------------------------------------------------------------------- /js/setStepper.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | ///////////////// Text surrounding the stepping circles /////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function setStepper() { 6 | 7 | ////////////////////////////////////////////////////// 8 | //////////////////////// Lines /////////////////////// 9 | ////////////////////////////////////////////////////// 10 | 11 | var stepLines = svg.append("g").attr("class","lineWrapper"); 12 | var boxWidth = 20, 13 | boxHeight = 38; 14 | var offsets_2 = document.getElementById('circle_2').getBoundingClientRect(); 15 | var offsets_4 = document.getElementById('circle_4').getBoundingClientRect(); 16 | var offsets_6 = document.getElementById('circle_6').getBoundingClientRect(); 17 | var offsets_8 = document.getElementById('circle_8').getBoundingClientRect(); 18 | 19 | //Map View 20 | /*stepLines.append("rect") 21 | .attr("class", "stepRect mapView") 22 | .attr("x", (offsets_2.left-4)) 23 | .attr("y", (offsets_2.top-44)) 24 | .attr("width", boxWidth) 25 | .attr("height", boxHeight);*/ 26 | 27 | stepLines.append("line") 28 | .attr("class", "stepLine mapView") 29 | .attr("x1", (offsets_2.left + 5)) 30 | .attr("x2", (offsets_2.left + 5)) 31 | .attr("y1", (offsets_2.top - 23)) 32 | .attr("y2", (offsets_2.top - 31)); 33 | 34 | stepLines.append("text") 35 | .attr("class", "stepText mapView") 36 | .style("text-anchor", "middle") 37 | .attr("x", (offsets_2.left + 5)) 38 | .attr("y", (offsets_2.top - 14)) 39 | .text("map"); 40 | 41 | //Slope View 42 | /*stepLines.append("rect") 43 | .attr("class", "stepRect slopeView") 44 | .attr("x", (offsets_4.left-4)) 45 | .attr("y", (offsets_4.top-70)) 46 | .attr("width", boxWidth) 47 | .attr("height", boxHeight);*/ 48 | 49 | stepLines.append("line") 50 | .attr("class", "stepLine slopeView") 51 | .attr("x1", (offsets_4.left + 5)) 52 | .attr("x2", (offsets_4.left + 5)) 53 | .attr("y1", (offsets_4.top - 57)) 54 | .attr("y2", (offsets_4.top - 49)); 55 | 56 | stepLines.append("text") 57 | .attr("class", "stepText slopeView") 58 | .style("text-anchor", "middle") 59 | .attr("x", (offsets_4.left + 5)) 60 | .attr("y", (offsets_4.top - 62)) 61 | .text("slope"); 62 | 63 | //Histogram View 64 | /*stepLines.append("rect") 65 | .attr("class", "stepRect histoView") 66 | .attr("x", (offsets_6.left-4)) 67 | .attr("y", (offsets_6.top-44)) 68 | .attr("width", boxWidth) 69 | .attr("height", boxHeight);*/ 70 | 71 | stepLines.append("line") 72 | .attr("class", "stepLine histoView") 73 | .attr("x1", (offsets_6.left + 5)) 74 | .attr("x2", (offsets_6.left + 5)) 75 | .attr("y1", (offsets_6.top - 23)) 76 | .attr("y2", (offsets_6.top - 31)); 77 | 78 | stepLines.append("text") 79 | .attr("class", "stepText histoView") 80 | .style("text-anchor", "middle") 81 | .attr("x", (offsets_6.left + 5)) 82 | .attr("y", (offsets_6.top - 14)) 83 | .text("histogram"); 84 | 85 | //Scatter View 86 | /*stepLines.append("rect") 87 | .attr("class", "stepRect scatterView") 88 | .attr("x", (offsets_8.left-4)) 89 | .attr("y", (offsets_8.top-70)) 90 | .attr("width", boxWidth) 91 | .attr("height", boxHeight);*/ 92 | 93 | stepLines.append("line") 94 | .attr("class", "stepLine scatterView") 95 | .attr("x1", (offsets_8.left + 5)) 96 | .attr("x2", (offsets_8.left + 5)) 97 | .attr("y1", (offsets_8.top - 57)) 98 | .attr("y2", (offsets_8.top - 49)); 99 | 100 | stepLines.append("text") 101 | .attr("class", "stepText scatterView") 102 | .style("text-anchor", "middle") 103 | .attr("x", (offsets_8.left + 5)) 104 | .attr("y", (offsets_8.top - 62)) 105 | .text("scatter"); 106 | 107 | }//setStepper -------------------------------------------------------------------------------- /js/slopeGraph.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////////////// Slopegraph //////////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | //Default initial 6 | var slopeTitle, 7 | firstSlope; 8 | 9 | //Initiate the scale for the vertical invisible lines of the slopegraph 10 | var slopeScale = d3.scale.linear().range([620,120]); 11 | 12 | //Location of the 2000 and 2010 vertical "lines" 13 | var xAxisLoc2000 = 200, 14 | xAxisLoc2010 = xAxisLoc2000 + 200; 15 | 16 | function callSlopeGraph() { 17 | 18 | //Change visual modus to slope 19 | modus = "Slope"; 20 | 21 | setTimeout(function() {counter = 5;}, 1000); 22 | 23 | //Set the progress circles 24 | setCircleProgress(4); 25 | 26 | ////////////////////////////////////////////////////// 27 | ////////////////// Hide & Remove ///////////////////// 28 | ////////////////////////////////////////////////////// 29 | 30 | //Activate the back button 31 | d3.select("#clickerBack").classed("activeButton",true); 32 | d3.select("#clickerBack").classed("inactiveButton",false); 33 | //Activate the front button 34 | d3.select("#clickerFront").classed("activeButton",true); 35 | d3.select("#clickerFront").classed("inactiveButton",false); 36 | //Change text of front button 37 | d3.select("#clickerFront").html("Continue"); 38 | 39 | //Reset the progress bar 40 | resetProgressBar(); 41 | 42 | //Remove the two bars - if present 43 | startBarChart.selectAll("g").remove(); 44 | 45 | //Show the buttons 46 | d3.select(".btn-group") 47 | .style("visibility", "visible"); 48 | 49 | //Remove the intro explanation 50 | d3.select("#explanationIntro") 51 | .transition().duration(1000) 52 | .style("opacity",0) 53 | .call(endall, function() { 54 | d3.select("#explanationIntro") 55 | .style("visibility","hidden"); 56 | }); 57 | 58 | //Make text & call-out disappear - if present 59 | d3.select("#explanation") 60 | .transition().duration(1000) 61 | .style("opacity",0) 62 | .call(endall, function() { 63 | d3.select("#explanation") 64 | .style("visibility","hidden"); 65 | }); 66 | 67 | //Remove map 68 | map.selectAll(".geo-path") 69 | .transition().duration(2000) 70 | .style("stroke-opacity", 0) 71 | .style("fill-opacity", 0) 72 | .call(endall, function() { 73 | map.selectAll(".geo-path") 74 | .attr("visibility", "hidden"); 75 | }); 76 | 77 | //Show the text & button on the right 78 | d3.select("#section") 79 | .transition().delay(100) 80 | .style("opacity",0) 81 | .call(endall, function() { 82 | d3.select("#section") 83 | .style("visibility","visible"); 84 | //Change title in top right corner 85 | d3.select("#sectionTitle") 86 | .style("opacity",1) 87 | .html("Creating the right kind of density in a city"); 88 | //Change text in top right corner 89 | d3.select("#sectionText") 90 | .html('

Urban population density, which was already high in the year 2000 for East Asia has only grown larger for practically all cities outside of China. Continuous growth can be expected in the coming years. Therefore, the focus for urban planners should be on the design of this density, the appropriate coordination and location of different city aspects

' + 91 | '

Click on the buttons below to see the differences of the urban population, urban land or urban population density per city or hover over the plots to get more detailed information

'); 92 | }) 93 | .transition().duration(1000) 94 | .style("opacity",1); 95 | 96 | //Show bar chart again 97 | initiateBarChart(); 98 | 99 | //Call slopegraph 100 | setTimeout(initiateSlopeGraph, 1100); 101 | 102 | //Remove color setting from dot-plot 103 | cities2010.selectAll(".city_2010") 104 | .style("fill","#DA6761") 105 | .style("fill-opacity", 0.8); 106 | 107 | //Remove dot histogram axis 108 | dotWrapper.selectAll("g").remove(); 109 | dotWrapper.selectAll("text").remove(); 110 | 111 | //Hide call-out 112 | d3.select("#callOut").style("visibility","hidden"); 113 | 114 | }//callSlopeGraph 115 | 116 | //Function to show the slopegraph 117 | function initiateSlopeGraph() { 118 | 119 | //Remove map 120 | map.selectAll(".geo-path") 121 | .transition().duration(2000) 122 | .style("stroke-opacity", 0) 123 | .style("fill-opacity", 0) 124 | .call(endall, function() { 125 | map.selectAll(".geo-path") 126 | .attr("visibility", "hidden"); 127 | }); 128 | 129 | //Change visual modus to slope 130 | modus = "Slope"; 131 | //Adds a small delay of the slope lines when drawn from the map modus 132 | firstSlope = true; 133 | 134 | //Make all elements visible again 135 | d3.selectAll(".slopeGraph") 136 | .attr("visibility", "visible") 137 | .transition().duration(1000) 138 | .style("opacity", 1); 139 | 140 | //Remove previous slope elements 141 | slopes.selectAll(".slopes").remove(); 142 | text2000.selectAll("text").remove(); 143 | text2010.selectAll("text").remove(); 144 | slopeTitles.selectAll("text").remove(); 145 | 146 | ////////////////////////////////////////////////////// 147 | ////////////////////// Initialize //////////////////// 148 | ////////////////////////////////////////////////////// 149 | 150 | //Initiate the lines for the slopegraph 151 | slopes.selectAll(".slopes") 152 | .data(data) 153 | .enter().append("line") 154 | .attr("class", "slopes") 155 | .style("stroke-width", 1) 156 | .attr("stroke", "#858483") 157 | .on("mouseover", showOne) 158 | .on("mouseout", showAll) 159 | .style("opacity", 0); 160 | 161 | //Initiate the text for 2000 datapoints 162 | text2000.selectAll("text") 163 | .data(data) 164 | .enter().append("text") 165 | .attr("class", "text2000") 166 | .style("text-anchor","end") 167 | .attr("font-size", 10) 168 | .attr("dy", ".4em") 169 | .style("cursor","default") 170 | .on("mouseover", showOne) 171 | .on("mouseout", showAll) 172 | .style("opacity", 0); 173 | 174 | //Initiate the text for 2010 datapoints 175 | text2010.selectAll("text") 176 | .data(data) 177 | .enter().append("text") 178 | .attr("class", "text2010") 179 | .style("text-anchor","start") 180 | .attr("font-size", 10) 181 | .attr("dy", ".3em") 182 | .style("cursor","default") 183 | .on("mouseover", showOne) 184 | .on("mouseout", showAll) 185 | .style("opacity", 0); 186 | 187 | ////////////////////////////////////////////////////// 188 | //////////////////// Titles on top /////////////////// 189 | ////////////////////////////////////////////////////// 190 | 191 | //2000 above left axis 192 | slopeTitles.append("text") 193 | .attr("class","title titleTop city_2010") 194 | .attr("x", xAxisLoc2000) 195 | .attr("y", slopeScale.range()[1] - 40) 196 | .style("text-anchor", "middle") 197 | .text("2000") 198 | .style("opacity", 0) 199 | .attr("visibility", "visible") 200 | .transition().duration(1000) 201 | .style("opacity", 1); 202 | //2010 above right axis 203 | slopeTitles.append("text") 204 | .attr("class","title titleTop") 205 | .attr("x", xAxisLoc2010) 206 | .attr("y", slopeScale.range()[1] - 40) 207 | .style("text-anchor", "middle") 208 | .style("fill", "#DA6761") 209 | .text("2010") 210 | .style("opacity", 0) 211 | .attr("visibility", "visible") 212 | .transition().duration(1000) 213 | .style("opacity", 1); 214 | //The title on top 215 | slopeTitles.append("text") 216 | .attr("class","titleTop top") 217 | .attr("x", (xAxisLoc2010 - xAxisLoc2000)/2 + xAxisLoc2000) 218 | .attr("y", slopeScale.range()[1] - 80) 219 | .style("text-anchor", "middle") 220 | .text(slopeTitle) 221 | .style("opacity", 0) 222 | .attr("visibility", "visible") 223 | .transition().duration(1000) 224 | .style("opacity", 1); 225 | 226 | //Create the slopegraph based on the dimension selected 227 | if (rVar == "pop") {totalPopulationSlopeGraph();}; 228 | if (rVar == "land") {totalUrbanLandSlopeGraph();}; 229 | if (rVar == "density") {totalDensitySlopeGraph();}; 230 | 231 | }//initiateSlopeGraph 232 | 233 | //Move circles to show Population between 2000 and 2010 234 | function totalPopulationSlopeGraph() { 235 | rVar = "pop"; 236 | slopeTitle = "Urban population [in millions]"; 237 | changeSlope(); 238 | }//totalPopulationSlopeGraph 239 | 240 | //Move circles to show Land between 2000 and 2010 241 | function totalUrbanLandSlopeGraph() { 242 | rVar = "land"; 243 | slopeTitle = "Urban land [in sq. km.]"; 244 | changeSlope(); 245 | }//totalUrbanLandSlopeGraph 246 | 247 | //Move circles to show Density between 2000 and 2010 248 | function totalDensitySlopeGraph() { 249 | rVar = "density"; 250 | slopeTitle = "Urban population density [in 1000 persons/sq. km]"; 251 | changeSlope(); 252 | }//totalDensitySlopeGraph 253 | 254 | //Actual function that sets the positions, lines and text of the slopgraph elements 255 | function changeSlope() { 256 | 257 | var dur = (firstSlope == true ? 2000 : 2000); 258 | var delaySlope = (firstSlope == true ? 500 : 0); 259 | 260 | //Create domains of the scale 261 | slopeScale.domain([d3.min(data, function(d) {return eval("d." + rVar + "_2000");}),d3.max(data, function(d) {return eval("d." + rVar + "_2010");})]); 262 | 263 | //Move city circles of 2000 to left axis 264 | cities2000.selectAll(".city_2000") 265 | .transition().duration(dur) 266 | .style("fill-opacity", 0.8) 267 | .attr("r", 3) 268 | .attr("cx", xAxisLoc2000) 269 | .attr("cy", function(d){return slopeScale(eval("d." + rVar + "_2000"));}); 270 | 271 | //Move city circles of 2010 to right axis 272 | cities2010.selectAll(".city_2010") 273 | .transition().duration(dur) 274 | .style("fill","#DA6761") 275 | .style("fill-opacity", 0.8) 276 | .attr("r", 3) 277 | .attr("cx", xAxisLoc2010) 278 | .attr("cy", function(d){return slopeScale(eval("d." + rVar + "_2010"));}); 279 | 280 | //Draw the lines between the points 281 | slopes.selectAll(".slopes") 282 | .transition().duration(dur/2).delay(delaySlope) 283 | .style("opacity", 0) 284 | .call(endall, function () { 285 | slopes.selectAll(".slopes") 286 | .attr("x1", xAxisLoc2000) 287 | .attr("x2", xAxisLoc2010) 288 | .attr("y1",function(d){return slopeScale(eval("d." + rVar + "_2000"));}) 289 | .attr("y2",function(d){return slopeScale(eval("d." + rVar + "_2010"));}) 290 | .transition().duration(dur) 291 | .style("opacity", 0.4) 292 | }); 293 | 294 | text2000.selectAll("text") 295 | .transition().duration(dur/2) 296 | .style("opacity", 0) 297 | .call(endall, function() { 298 | text2000.selectAll("text") 299 | .attr("x", xAxisLoc2000 - 10) 300 | .attr("y", function(d){return slopeScale(eval("d." + rVar + "_2000"));}) 301 | .text(function(d) { 302 | if (rVar == "pop") { 303 | if (d.pop_2000 > 1e6) {return d.city + ", " + d.country + " | " + numFormatOne(d.pop_2000/1e6);} 304 | else {return d.city + ", " + d.country + " | " + numFormatTwo(d.pop_2000/1e6);} 305 | } else if (rVar == "land") { 306 | return d.city + ", " + d.country + " | " + d.land_2000; 307 | } else if (rVar == "density") { 308 | return d.city + ", " + d.country + " | " + numFormatTwo(d.density_2000/1e3); 309 | }//else if 310 | }) 311 | .filter(function(d) { return eval("d.rank_" + rVar + " < 10");}) 312 | .transition().duration(dur/2) 313 | .style("opacity", 0.7) 314 | }); 315 | 316 | text2010.selectAll("text") 317 | .transition().duration(dur/2) 318 | .style("opacity", 0) 319 | .call(endall, function() { 320 | text2010.selectAll("text") 321 | .attr("x", xAxisLoc2010 + 10) 322 | .attr("y", function(d){return slopeScale(eval("d." + rVar + "_2010"));}) 323 | .text(function(d) { 324 | if (rVar == "pop") { 325 | if (d.pop_2000 > 1e6) {return numFormatOne(d.pop_2010/1e6) + " | " + d.city + ", " + d.country;} 326 | else {return numFormatTwo(d.pop_2010/1e6) + " | " + d.city + ", " + d.country; } 327 | } else if (rVar == "land") { 328 | return d.land_2010 + " | " + d.city + ", " + d.country; 329 | } else if (rVar == "density") { 330 | return numFormatTwo(d.density_2010/1e3) + " | " + d.city + ", " + d.country; 331 | }//else if 332 | }) 333 | .filter(function(d) { return eval("d.rank_" + rVar + " < 10");}) 334 | .transition().duration(dur/2) 335 | .style("opacity", 0.7) 336 | }); 337 | 338 | slopeGraph.selectAll(".top") 339 | .text(slopeTitle); 340 | 341 | firstSlope = false; 342 | }//changeSlope -------------------------------------------------------------------------------- /js/startBar.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | ///////////////////////////// First Bar Chart ///////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | function startBar() { 6 | 7 | modus = "startBar"; 8 | rVar == "pop"; 9 | setTimeout(function() {counter = 2;}, 1000); 10 | 11 | //Activate the back button 12 | d3.select("#clickerBack").classed("activeButton",true); 13 | d3.select("#clickerBack").classed("inactiveButton",false); 14 | //Change text of front button 15 | d3.select("#clickerFront").html("Continue"); 16 | 17 | ////////////////////////////////////////////////////// 18 | ////////////////// Hide & Remove ///////////////////// 19 | ////////////////////////////////////////////////////// 20 | 21 | //Reset the progress bar 22 | resetProgressBar(); 23 | 24 | //Set the progress circles 25 | setCircleProgress(1); 26 | 27 | //Remove the intro explanation 28 | d3.select("#explanationIntro") 29 | .transition().duration(1000) 30 | .style("opacity",0) 31 | .call(endall, function() { 32 | d3.select("#explanationIntro") 33 | .style("visibility","hidden"); 34 | }); 35 | 36 | //Remove all elements of startBarChart (if present) 37 | startBarChart.selectAll("g").remove(); 38 | 39 | //Hide call-out 40 | d3.select("#callOut").style("visibility","hidden"); 41 | 42 | d3.select("#section") 43 | .style("opacity",0) 44 | .style("visibility","hidden"); 45 | 46 | //Remove the bar chart to the right - if present 47 | barChart.selectAll("g").remove(); 48 | barWrappingOther.selectAll("g").remove(); 49 | 50 | //Hide the cities - if present 51 | cities2010.selectAll(".city_2010") 52 | .on("mouseover", null) 53 | .on("mouseout", null) 54 | .transition().duration(1000) 55 | .attr("r", 0) 56 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 57 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 58 | cities2000.selectAll(".city_2000") 59 | .on("mouseover", null) 60 | .on("mouseout", null) 61 | .transition().duration(1000) 62 | .attr("r", 0) 63 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 64 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 65 | 66 | //Hide the buttons - if present 67 | d3.select(".btn-group") 68 | .style("visibility", "hidden"); 69 | 70 | //Remove dot histogram axis 71 | dotWrapper.selectAll("g").remove(); 72 | dotWrapper.selectAll("text").remove(); 73 | 74 | ////////////////////////////////////////////////////// 75 | ////////////////////// Initialize //////////////////// 76 | ////////////////////////////////////////////////////// 77 | 78 | var delay = 5000; 79 | 80 | //Start the progress bar 81 | runProgressBar(delay*8.6); 82 | 83 | //Set the bar chart dimension and location 84 | var barTotalHeight = 500, 85 | barWidth = 35, 86 | loc2000bar = 25, 87 | loc2010bar = 100; 88 | 89 | startBarChart.attr("width", 600) 90 | .attr("height", barTotalHeight) 91 | .attr("transform","translate(100,75)"); 92 | 93 | var total2000 = d3.sum(countries, function(d) {return d.pop_2000;}); 94 | var total2010 = d3.sum(countries, function(d) {return d.pop_2010;}); 95 | 96 | var yScale = d3.scale.linear() 97 | .range([0, barTotalHeight]) 98 | .domain([0,d3.sum(countries, function(d) {return d.pop_2010;})]) 99 | 100 | var startBar2000 = startBarChart.append("g").attr("class","bar2000"); 101 | var startBar2010 = startBarChart.append("g").attr("class","bar2010"); 102 | 103 | ////////////////////////////////////////////////////// 104 | ///////////////////////// Map //////////////////////// 105 | ////////////////////////////////////////////////////// 106 | 107 | //Increase opacity of the map 108 | map.selectAll(".geo-path") 109 | .attr("visibility", "visible") 110 | .transition().duration(2000) 111 | .style("stroke-opacity", 1) 112 | .style("fill-opacity", 0.6); 113 | 114 | //The number of cities 115 | d3.select("#explanation") 116 | .transition().duration(1000) 117 | .style("opacity",0) 118 | .call(endall, function() { 119 | d3.select("#explanation") 120 | .style("visibility","visible") 121 | .style("top", 350 + "px") 122 | .style("left", 400 + "px") 123 | .style("width", 450 + "px") 124 | .html("Data is available on the 869 urban areas in the region with populations over 100,000 in 2010"); 125 | }) 126 | .transition().duration(1000) 127 | .style("opacity",1); 128 | //Show the 869 cities small in the background 129 | cities2000.selectAll(".city_2000") 130 | .transition().duration(2000) 131 | .style("fill-opacity", 0.3) 132 | .attr("r", 1.5); 133 | 134 | ////////////////////////////////////////////////////// 135 | /////////////////////// Bar 2000 ///////////////////// 136 | ////////////////////////////////////////////////////// 137 | //The number of people in 2000 138 | explanationText(varText = "The 580 million people that were already living in these cities in 2000 grew to 780 million in 2010", delay = delay, delayStep = 1); 139 | 140 | //Create the 2000 grey bar 141 | startBar2000.append("rect") 142 | .attr("x", loc2000bar) 143 | .attr("y", barTotalHeight) 144 | .attr("class","city_2000") 145 | .attr("width", barWidth) 146 | .attr("height", 0) 147 | .transition().duration(2000).delay(delay*1) 148 | .attr("height", yScale(total2000)) 149 | .attr("y", (barTotalHeight - yScale(total2000))); 150 | //Append the year 2000 at the bottom 151 | startBar2000.append("text") 152 | .attr("class", "city_2000") 153 | .attr("x", (loc2000bar + barWidth/2)) 154 | .attr("y", (barTotalHeight + 20)) 155 | .attr("text-anchor", "middle") 156 | .style("font-size", 14) 157 | .text(2000) 158 | .style("opacity", 0) 159 | .transition().duration(1000).delay(delay*1) 160 | .style("opacity", 1); 161 | //Text inside the 2000 bar 162 | startBar2000.append("text") 163 | .attr("class", "city_2000 startbar-inside") 164 | .attr("x", (loc2000bar + barWidth/2)) 165 | .attr("y", (barTotalHeight - yScale(total2000) + 15)) 166 | .style("text-anchor", "middle") 167 | .style("fill", "white") 168 | .text(numFormatSI(total2000)) 169 | .style("opacity", 0) 170 | .transition().duration(1000).delay(delay*1+2000) 171 | .style("opacity", 1); 172 | 173 | ////////////////////////////////////////////////////// 174 | /////////////////////// Bar 2010 ///////////////////// 175 | ////////////////////////////////////////////////////// 176 | 177 | //The number of people in 2010 178 | explanationText(varText = "", delay = delay, delayStep = 2); 179 | 180 | //Create the 2010 reddish bar 181 | startBar2010.append("rect") 182 | .attr("x", loc2010bar) 183 | .attr("y", barTotalHeight) 184 | .attr("class","city_2010") 185 | .attr("width", barWidth) 186 | .attr("height", 0) 187 | .transition().duration(2000).delay(delay*1)//First grow to 2000 number 188 | .attr("height", yScale(total2000)) 189 | .attr("y", (barTotalHeight - yScale(total2000))) 190 | .transition().duration(1500).delay(delay*1+2500)//Then grow to 2010 number 191 | .attr("height", yScale(total2010)) 192 | .attr("y", (barTotalHeight - yScale(total2010))); 193 | 194 | //Append the year 2010 at the bottom 195 | startBar2010.append("text") 196 | .attr("class", "city_2010") 197 | .attr("x", (loc2010bar + barWidth/2)) 198 | .attr("y", (barTotalHeight + 20)) 199 | .attr("text-anchor", "middle") 200 | .style("font-size", 14) 201 | .text(2010) 202 | .style("opacity", 0) 203 | .transition().duration(1000).delay(delay*1) 204 | .style("opacity", 1); 205 | //Text inside the 2010 bar 206 | startBar2010.append("text") 207 | .attr("class", "city_2010 startbar-inside") 208 | .attr("x", (loc2010bar + barWidth/2)) 209 | .attr("y", (barTotalHeight - yScale(total2010) + 15)) 210 | .style("text-anchor", "middle") 211 | .style("fill", "white") 212 | .text(numFormatSI(total2010)) 213 | .style("opacity", 0) 214 | .transition().duration(1000).delay(delay*1+3000) 215 | .style("opacity", 1); 216 | 217 | 218 | ////////////////////////////////////////////////////// 219 | ///////////////////// Difference ///////////////////// 220 | ////////////////////////////////////////////////////// 221 | //Growth 222 | explanationText(varText = "

That is an increase of 34% in just 10 years, a difference of 200 million people

This would be the world’s sixth-largest population for any single country

", delay = delay, delayStep = 2); 223 | 224 | //Dashed vertical line 225 | startBar2000.append("line") 226 | .attr("x1", (loc2000bar + barWidth/2)) 227 | .attr("x2", (loc2000bar + barWidth/2)) 228 | .attr("y1", yScale(total2010-total2000)) 229 | .attr("y2", yScale(total2010-total2000)) 230 | .style("stroke","#AAAAAA") 231 | .style("stroke-dasharray", ("7, 4")) 232 | .style("stroke-width", 1.5) 233 | .transition().duration(2000).delay(delay*2) 234 | .attr("y2", 2); 235 | //Horizontal line 236 | startBar2000.append("line") 237 | .attr("x1", loc2000bar) 238 | .attr("x2", (loc2000bar + barWidth)) 239 | .attr("y1", 2) 240 | .attr("y2", 2) 241 | .style("stroke","#AAAAAA") 242 | .style("stroke-width", 1.5) 243 | .style("opacity", 0) 244 | .transition().duration(500).delay(delay*2+1500) 245 | .style("opacity", 1); 246 | 247 | //Make text disappear 248 | d3.select("#explanation") 249 | .transition().duration(1000).delay(delay*3.4) 250 | .style("opacity",0) 251 | .call(endall, function() { 252 | d3.select("#explanation") 253 | .style("visibility","hidden"); 254 | }); 255 | 256 | //Remove lines above 2000 257 | startBar2000.selectAll("line") 258 | .transition().duration(1000).delay(delay*3.4) 259 | .style("opacity", 0) 260 | .call(endall, function() { 261 | startBar2000.selectAll("line") 262 | .remove(); 263 | }); 264 | 265 | setTimeout(introduceCities, delay*3.4); 266 | 267 | }//startBar -------------------------------------------------------------------------------- /js/totalAreaMap.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | /////////////////////////////// Map View ////////////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | var rScale = d3.scale.sqrt(); 6 | var rVar = "pop"; 7 | 8 | //This function shows the map and moves the circles to their geo locations 9 | function totalAreaMap() { 10 | 11 | setTimeout(function() {counter = 3;}, 1000); 12 | 13 | modus = "Map"; 14 | 15 | //Set the progress circles 16 | setCircleProgress(2); 17 | 18 | ////////////////////////////////////////////////////// 19 | ////////////////// Hide & Remove ///////////////////// 20 | ////////////////////////////////////////////////////// 21 | 22 | //Activate the back button 23 | d3.select("#clickerBack").classed("activeButton",true); 24 | d3.select("#clickerBack").classed("inactiveButton",false); 25 | //Activate the front button 26 | d3.select("#clickerFront").classed("activeButton",true); 27 | d3.select("#clickerFront").classed("inactiveButton",false); 28 | //Change text of front button 29 | d3.select("#clickerFront").html("Continue"); 30 | 31 | //Remove the intro explanation 32 | d3.select("#explanationIntro") 33 | .transition().duration(1000) 34 | .style("opacity",0) 35 | .call(endall, function() { 36 | d3.select("#explanationIntro") 37 | .style("visibility","hidden"); 38 | }); 39 | 40 | //Show the buttons 41 | d3.select(".btn-group") 42 | .style("visibility", "visible"); 43 | 44 | //Remove the two bars - if present 45 | startBarChart.selectAll("g").remove(); 46 | 47 | //Reset the progress bar 48 | resetProgressBar(); 49 | 50 | //Remove slopegraph elements - if present 51 | slopes.selectAll(".slopes").remove(); 52 | text2000.selectAll("text").remove(); 53 | text2010.selectAll("text").remove(); 54 | slopeTitles.selectAll("text").remove(); 55 | 56 | //Remove color setting from dot-plot 57 | cities2010.selectAll(".city_2010") 58 | .style("fill","#DA6761"); 59 | 60 | //Remove dot histogram axis & text - if present 61 | dotWrapper.selectAll("g").remove(); 62 | dotWrapper.selectAll("text").remove(); 63 | 64 | //Make text & call-out disappear - if present 65 | d3.select("#explanation") 66 | .transition().duration(1000) 67 | .style("opacity",0) 68 | .call(endall, function() { 69 | d3.select("#explanation") 70 | .style("visibility","hidden"); 71 | 72 | d3.select("#callOut").style("visibility","hidden"); 73 | }); 74 | 75 | ////////////////////////////////////////////////////// 76 | ////////////////////// Initialize //////////////////// 77 | ////////////////////////////////////////////////////// 78 | 79 | //Show the text in the top right corner 80 | d3.select("#section") 81 | .style("visibility","visible") 82 | .transition().duration(1000) 83 | .style("opacity",1); 84 | 85 | //Show the text & button on the right 86 | d3.select("#section") 87 | .transition().delay(100) 88 | .style("opacity",0) 89 | .call(endall, function() { 90 | d3.select("#section") 91 | .style("visibility","visible"); 92 | //Change title in top right corner 93 | d3.select("#sectionTitle") 94 | .style("opacity",1) 95 | .html("Cities with over 100,000 inhabitants"); 96 | //Change text in top right corner 97 | d3.select("#sectionText") 98 | .html('

The urban areas in this research have 100,000 or more inhabitants in 2010. In 2000 there were already 580 million people living in these 869 cities and just one decade on this number grew to 780 million. That’s 200 million people more!
With this amount of people of the move, it becomes imperative for cities to plan for their arrival in terms of housing and infrastructure

' + 99 | '

Click on the buttons below to see the differences of the urban population, urban land or urban population density per city or hover over the plots to get more detailed information

'); 100 | }) 101 | .transition().duration(1000) 102 | .style("opacity",1); 103 | 104 | //Increase opacity of the map 105 | map.selectAll(".geo-path") 106 | .attr("visibility", "visible") 107 | .style("stroke-opacity", 1) 108 | .style("fill-opacity", 1); 109 | 110 | setTimeout(initiateBarChart(), 1000); 111 | 112 | //Plot the sizes of the cities in 2010 in reddish 113 | //On the same location plot the sizes of the cities in 2000 in greyish 114 | if (rVar == "pop") {totalPopulationMap();}; 115 | if (rVar == "land") {totalUrbanLandMap();}; 116 | if (rVar == "density") {totalDensityMap();}; 117 | 118 | }//totalAreaMap 119 | 120 | function totalPopulationMap() { 121 | rScale.domain([d3.min(data, function(d) {return d.pop_2000;}),d3.max(data, function(d) {return d.pop_2010;})]) 122 | .range([1,20]); 123 | rVar = "pop" 124 | changeMap(); 125 | }//totalPopulationMap 126 | 127 | function totalUrbanLandMap() { 128 | rScale.domain([d3.min(data, function(d) {return d.land_2000;}),d3.max(data, function(d) {return d.land_2010;})]) 129 | .range([1,20]); 130 | rVar = "land" 131 | changeMap(); 132 | }//totalUrbanLandMap 133 | 134 | function totalDensityMap() { 135 | rScale.domain([d3.min(data, function(d) {return d.density_2000;}),d3.max(data, function(d) {return d.density_2010;})]) 136 | .range([1,8]); 137 | rVar = "density" 138 | changeMap(); 139 | }//totalDensityMap 140 | 141 | //Change the dots on the map 142 | function changeMap() { 143 | //Plot the sizes of the cities in 2010 in reddish 144 | cities2010.selectAll(".city_2010") 145 | .on("mouseover", showOne) 146 | .on("mouseout", showAll) 147 | .transition().duration(1500) 148 | .attr("r", function(d) {return eval("rScale(d." + rVar + "_2010)");}) 149 | .style("fill-opacity", 0.5) 150 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 151 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 152 | 153 | //On the same location plot the sizes of the cities in 2000 in greyish 154 | cities2000.selectAll(".city_2000") 155 | .on("mouseover", showOne) 156 | .on("mouseout", showAll) 157 | .transition().duration(1500) 158 | .attr("r", function(d) {return eval("rScale(d." + rVar + "_2000)");}) 159 | .style("fill-opacity", 0.7) 160 | .attr("cx", function(d) {return projection([d.longitude, d.latitude])[0];}) 161 | .attr("cy", function(d) {return projection([d.longitude, d.latitude])[1];}); 162 | }//changeMap -------------------------------------------------------------------------------- /js/urbanPopDot.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | ///////////////////////////// Scatter plot GDP //////////////////////////// 3 | /////////////////////////////////////////////////////////////////////////// 4 | 5 | var yBarScale = d3.scale.linear(); 6 | var barDimWidth = 400, 7 | barDimHeight = 500, 8 | barX = 50, 9 | barY = 40, 10 | dotSize = 6; 11 | 12 | function callScatter() { 13 | 14 | setTimeout(function() {counter = 9;}, 1000); 15 | 16 | //Set the progress circles 17 | setCircleProgress(8); 18 | 19 | ////////////////////////////////////////////////////// 20 | ////////////////// Hide & Remove ///////////////////// 21 | ////////////////////////////////////////////////////// 22 | 23 | //Activate the back button 24 | d3.select("#clickerBack").classed("activeButton",true); 25 | d3.select("#clickerBack").classed("inactiveButton",false); 26 | //Activate the front button 27 | d3.select("#clickerFront").classed("activeButton",true); 28 | d3.select("#clickerFront").classed("inactiveButton",false); 29 | d3.select("#clickerFront").html("Finish"); 30 | 31 | //Reset the progress bar 32 | resetProgressBar(); 33 | 34 | //Remove the two bars - if present 35 | startBarChart.selectAll("g").remove(); 36 | 37 | //Hide call-out 38 | d3.select("#callOut").style("visibility","hidden"); 39 | 40 | //Remove previous slope elements 41 | slopes.selectAll(".slopes").remove(); 42 | text2000.selectAll("text").remove(); 43 | text2010.selectAll("text").remove(); 44 | slopeTitles.selectAll("text").remove(); 45 | 46 | //Show the text & button on the right 47 | d3.select("#section") 48 | .transition().delay(100) 49 | .style("opacity",0) 50 | .call(endall, function() { 51 | d3.select("#section") 52 | .style("visibility","visible"); 53 | 54 | //Change title in top right corner 55 | d3.select("#sectionTitle") 56 | .html("Urbanization and economic prosperity"); 57 | //Change text in top right corner 58 | d3.select("#sectionText") 59 | .html('

Even though it would almost appear as if all inhabitants of East Asia live in cities, the large majority of the citizens currently still live in rural areas. Continuous urban growth is therefore expected to occur in the coming decades

' + 60 | '

The current view reveals a correlation between a rise in the urban population as a percentage to the whole population and an increase in the GDP (for the countries where GDP information is available) showing a glance of the possible economic prosperity that continuous urban growth might bring to an urban area and people that might move here in the coming future

' + 61 | '

For now, one can only speculate about the impact the continuous move towards cities will have on the social and economic circumstances of these families and areas. However, with more investment into research on the factors that influence the positive side of urbanization a future might be created in which more urban areas can be a place of constant development and continuous economic and social opportunities

' + 62 | '

To see which country belongs to each circle-line element hover over the plot on the left

'); 63 | }) 64 | .transition().duration(1000) 65 | .style("opacity",1); 66 | 67 | //Hide the buttons 68 | d3.select(".btn-group") 69 | .style("visibility", "hidden"); 70 | 71 | //Remove the intro explanation 72 | d3.select("#explanationIntro") 73 | .transition().duration(1000) 74 | .style("opacity",0) 75 | .call(endall, function() { 76 | d3.select("#explanationIntro") 77 | .style("visibility","hidden"); 78 | }); 79 | 80 | //Make text & call-out disappear - if present 81 | d3.select("#explanation") 82 | .transition().duration(1000) 83 | .style("opacity",0) 84 | .call(endall, function() { 85 | d3.select("#explanation") 86 | .style("visibility","hidden"); 87 | }); 88 | 89 | //Remove map - if present 90 | map.selectAll(".geo-path") 91 | .transition().duration(2000) 92 | .style("stroke-opacity", 0) 93 | .style("fill-opacity", 0) 94 | .call(endall, function() { 95 | map.selectAll(".geo-path") 96 | .attr("visibility", "hidden"); 97 | }); 98 | 99 | //Remove dot histogram axis & text 100 | dotWrapper.selectAll("g") 101 | .transition().duration(1000) 102 | .style("opacity", 0) 103 | .remove(); 104 | dotWrapper.selectAll("text") 105 | .transition().duration(1000) 106 | .style("opacity", 0) 107 | .remove(); 108 | 109 | //Remove 2000 cities 110 | cities2000.selectAll(".city_2000") 111 | .transition().duration(1000) 112 | .attr("r", 0) 113 | .style("fill-opacity", 0); 114 | 115 | //Remove 2010 cities 116 | cities2010.selectAll(".city_2010") 117 | .style("fill", null) 118 | .transition().duration(1000) 119 | .attr("r", 0) 120 | .style("fill-opacity", 0); 121 | 122 | //Remove all previous elements of the bar chart 123 | barChart.selectAll("g").remove(); 124 | barWrappingOther.selectAll("g").remove(); 125 | 126 | ////////////////////////////////////////////////////// 127 | ////////////////////// Initialize //////////////////// 128 | ////////////////////////////////////////////////////// 129 | 130 | 131 | //Set the new x axis range 132 | barScale 133 | .range([0, barDimWidth]) 134 | .domain([0,0.7]); 135 | //Set new x-axis 136 | xAxis 137 | .ticks(8) 138 | .scale(barScale) 139 | .tickFormat(numFormatPercent); 140 | 141 | //Set the new y axis range 142 | yBarScale 143 | .range([barDimHeight,100]) 144 | .domain([0, 70000]); 145 | yAxis 146 | .tickFormat(numFormatCurrency) 147 | .scale(yBarScale); 148 | 149 | //Move bar chart to the new location 150 | barChart 151 | .style("visibility","visible") 152 | .attr("width", barDimWidth) 153 | .attr("height", barDimHeight) 154 | .attr("transform","translate(" + barX + "," + barY + ")") 155 | .style("opacity",0) 156 | .transition().duration(1000) 157 | .style("opacity",1); 158 | //Move the axes wrapper 159 | barWrappingOther 160 | .style("visibility","visible") 161 | .attr("width", barDimWidth) 162 | .attr("height", 20) 163 | .attr("transform","translate(" + barX + ", " + (barY + barDimHeight) +")") 164 | .style("opacity",0) 165 | .transition().duration(1000) 166 | .style("opacity",1); 167 | 168 | //Create a group for each bar 169 | var bar = barChart.selectAll("g") 170 | .data(countries) 171 | .enter().append("g") 172 | .filter(function(d) {return d.country != "Singapore" & d.gdp_2000 != 0;}) 173 | .attr("class", "barWrapper") 174 | .style("visibility","visible") 175 | .attr("transform", function(d, i) { return "translate(75,0)"; }); 176 | 177 | //Already append a few lines for later 178 | bar.append("line") 179 | .attr("class", "line-connect") 180 | .style("stroke-width", 1) 181 | .attr("stroke", "#858483") 182 | .style("opacity", 0); 183 | 184 | //Create the 2010 circles 185 | bar.append("rect") 186 | .attr("class","city_2010") 187 | .style("fill-opacity", 0) 188 | .attr("rx",dotSize) 189 | .attr("ry",dotSize) 190 | .attr("width",dotSize) 191 | .attr("height",dotSize) 192 | .attr("transform", function (d) { 193 | return "translate(" + (barScale(d.pop_perc_2010) - dotSize/2) + "," + (yBarScale(d.gdp_2010) - dotSize/2) + ")"; 194 | }); 195 | 196 | //Create the 2010 circles 197 | bar.append("rect") 198 | .attr("class","city_2000") 199 | .style("fill-opacity", 0) 200 | .attr("rx",dotSize) 201 | .attr("ry",dotSize) 202 | .attr("width",dotSize) 203 | .attr("height",dotSize) 204 | .attr("transform", function (d) { 205 | return "translate(" + (barScale(d.pop_perc_2000) - dotSize/2) + "," + (yBarScale(d.gdp_2000) - dotSize/2) + ")"; 206 | }); 207 | 208 | //Append the x-axis 209 | barWrappingOther.append("g") 210 | .attr("class", "x axis") 211 | .attr("transform", "translate(75," + 10 + ")"); 212 | 213 | //Append the y-axis 214 | barWrappingOther.append("g") 215 | .attr("class", "y axis"); 216 | 217 | //Create the x axis 218 | barWrappingOther.selectAll(".x.axis") 219 | .style("opacity", 0) 220 | .call(xAxis) 221 | .transition().duration(1000).delay(1000) 222 | .style("opacity", 1); 223 | barWrappingOther.selectAll(".x.axis text") 224 | .style("font-size", "10px"); 225 | //Set up X axis label 226 | barWrappingOther.append("g") 227 | .append("text") 228 | .attr("class", "x label titleTop") 229 | .attr("text-anchor", "middle") 230 | .attr("transform", "translate(" + (75 + barDimWidth/2) + "," + 60 + ")") 231 | .style("font-size", "15px") 232 | .style("opacity", 0) 233 | .text("% of population living in urban areas of 100,000 people or more") 234 | .transition().duration(1000).delay(1000) 235 | .style("opacity", 1); 236 | 237 | setTimeout(createScatter, 1000); 238 | 239 | }//callScatter 240 | 241 | function createScatter() { 242 | 243 | d3.select("#clickerFront").html("Finish"); 244 | 245 | //Create the y axis 246 | barWrappingOther.select(".y.axis") 247 | .attr("transform", "translate(65," + -barDimHeight + ")") 248 | .style("opacity", 0) 249 | .transition().duration(1000) 250 | .style("opacity", 1) 251 | .call(yAxis); 252 | barWrappingOther.selectAll(".y.axis text") 253 | .style("font-size", "10px"); 254 | 255 | //Set up y axis label 256 | barWrappingOther.append("g") 257 | .append("text") 258 | .attr("class", "y label titleTop") 259 | .attr("text-anchor", "middle") 260 | .attr("transform", "translate(65, " + -(55+barDimHeight-100) + ")") 261 | .style("font-size", "15px") 262 | .style("opacity", 0) 263 | .text("GDP per capita") 264 | .transition().duration(1000) 265 | .style("opacity", 1); 266 | barWrappingOther.append("g") 267 | .append("text") 268 | .attr("class", "y label subTitle") 269 | .attr("transform", "translate(65, " + -(35+barDimHeight-100) + ")") 270 | .style("opacity", 0) 271 | .text("purchasing power parity") 272 | .transition().duration(1000) 273 | .style("opacity", 1); 274 | barWrappingOther.append("g") 275 | .append("text") 276 | .attr("class", "y label subTitle") 277 | .attr("transform", "translate(65, " + -(19+barDimHeight-100) + ")") 278 | .style("opacity", 0) 279 | .text("current international $") 280 | .transition().duration(1000) 281 | .style("opacity", 1); 282 | 283 | //Move the 2000 dots to the correct height 284 | barChart.selectAll(".city_2000") 285 | .on("mouseover", countryHover) 286 | .on("mouseout", countryOut) 287 | .transition().duration(1000) 288 | .style("fill-opacity", 1) 289 | .attr("transform", function (d) { 290 | return "translate(" + (barScale(d.pop_perc_2000) - dotSize/2) + "," + (yBarScale(d.gdp_2000) - dotSize/2) + ")"; 291 | }); 292 | //Move the 2010 dots to the correct height 293 | barChart.selectAll(".city_2010") 294 | .on("mouseover", countryHover) 295 | .on("mouseout", countryOut) 296 | .transition().duration(1000) 297 | .style("fill-opacity", 1) 298 | .attr("transform", function (d) { 299 | return "translate(" + (barScale(d.pop_perc_2010) - dotSize/2) + "," + (yBarScale(d.gdp_2010) - dotSize/2) + ")"; 300 | }); 301 | 302 | //Move the lines between the dots to the correct height 303 | barChart.selectAll("line") 304 | .on("mouseover", countryHover) 305 | .on("mouseout", countryOut) 306 | .transition().duration(1000) 307 | .style("opacity", 1) 308 | .attr("x1", function(d) {return barScale(d.pop_perc_2000);}) 309 | .attr("x2", function(d) {return barScale(d.pop_perc_2010);}) 310 | .attr("y1", function(d) {return yBarScale(d.gdp_2000);}) 311 | .attr("y2", function(d) {return yBarScale(d.gdp_2010);}); 312 | 313 | 314 | }//createScatter 315 | 316 | //Show country name in the last GDP scatterplot 317 | function countryHover(d) { 318 | //Change the numbers to reflect the hovered over city 319 | d3.select("#callOutCountry").html(d.country); 320 | //Make the callOut visible again 321 | d3.select("#callOutCountryWrapper") 322 | .style("visibility","visible") 323 | //.transition().duration(500) 324 | .style("opacity", 1); 325 | }//countryHover 326 | 327 | //Hide callout again 328 | function countryOut() { 329 | //Make the callOut hidden 330 | d3.select("#callOutCountryWrapper") 331 | .transition().duration(500) 332 | .style("opacity", 0) 333 | .call(endall, function() { 334 | d3.select("#callOutCountryWrapper") 335 | .style("visibility","hidden"); 336 | }); 337 | }//countryOut 338 | --------------------------------------------------------------------------------