-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp21.html
More file actions
335 lines (289 loc) · 11.2 KB
/
p21.html
File metadata and controls
335 lines (289 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>21 Charts for World's Largest Countries</title>
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
<!-- TODO: ADD CircularStd Font -->
<style>
/* Import Circular Std (Medium) from GitHub raw URL */
@font-face {
font-family: 'CircularStd';
src: url('https://raw.githubusercontent.com/EconomicsObservatory/ECOvisualisations/main/guidelines/fonts/Circular/CircularStd-Medium.otf') format('opentype');
font-weight: 500;
font-style: normal;
font-display: swap;
}
/* Alias to support charts that reference 'Circular Std' */
@font-face {
font-family: 'Circular Std';
src: url('https://raw.githubusercontent.com/EconomicsObservatory/ECOvisualisations/main/guidelines/fonts/Circular/CircularStd-Medium.otf') format('opentype');
font-weight: 500;
font-style: normal;
font-display: swap;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
/* font-family: 'CircularStd', 'Circular Std', 'Metric Web', system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue"; */
line-height: 1.6;
color: #333;
background-color: #f5f5f5;
}
.vega-embed {
font-family: 'CircularStd', 'Circular Std', 'Metric Web', system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue";
}
.header {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
.intro-section {
background-color: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin-bottom: 2rem;
}
.intro-section h1 {
font-size: 2.5rem;
margin-bottom: 1.5rem;
color: #1a365d;
}
.intro-section p {
font-size: 1.1rem;
margin-bottom: 1.5rem;
color: #4a5568;
max-width: 70ch;
}
.highlight {
color: #2563eb;
font-weight: 500;
}
.treemap-container {
margin: 2rem 0;
background-color: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.treemap-container svg {
width: 100%;
height: auto;
max-height: 600px;
}
.container {
display: flex;
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
gap: 2rem;
}
.sidebar {
width: 250px;
flex-shrink: 0;
}
.sidebar-content {
position: sticky;
top: 2rem;
background-color: white;
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.category {
margin-bottom: 1rem;
padding: 0.75rem;
border-radius: 6px;
font-weight: 500;
transition: background-color 0.3s;
}
.category.active {
background-color: #f0f0f0;
color: #2563eb;
}
.main-content {
flex-grow: 1;
}
.section {
margin-bottom: 4rem;
}
.section-title {
font-size: 1.5rem;
margin-bottom: 2rem;
padding-bottom: 0.5rem;
border-bottom: 2px solid #2563eb;
}
.chart-container {
background-color: white;
padding: 2rem;
margin-bottom: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.chart-title {
font-size: 1.2rem;
margin-bottom: 1rem;
color: #1f2937;
}
@media (max-width: 768px) {
.container {
flex-direction: column;
}
.sidebar {
width: 100%;
}
.sidebar-content {
position: static;
}
}
</style>
</head>
<body>
<header class="header">
<div class="intro-section">
<h1>21 Charts for World's Largest Countries</h1>
<p>An in-depth exploration of the world's 21 most populous nations, which collectively represent <span class="highlight">over 70% of the global population</span>. This project compares key economic, demographic, and social indicators across these influential countries.</p>
<div class="treemap-container">
<object data="charts/p21/C1_Population_World.svg" type="image/svg+xml" style="width: 100%; max-width: 800px;">
Your browser does not support SVG
</object>
</div>
</div>
</header>
<div class="container">
<aside class="sidebar">
<div class="sidebar-content">
<div class="category" data-category="population">Population</div>
<div class="category" data-category="gdp">GDP</div>
<div class="category" data-category="labour">Labour Market</div>
<div class="category" data-category="fiscal">Fiscal</div>
<div class="category" data-category="monetary">Monetary</div>
</div>
</aside>
<main class="main-content">
<section id="population" class="section">
<h2 class="section-title">Population</h2>
<div class="chart-container" id="chart1"></div>
<div class="chart-container" id="chart2"></div>
<div class="chart-container" id="chart3"></div>
<div class="chart-container" id="chart4"></div>
</section>
<section id="gdp" class="section">
<h2 class="section-title">GDP</h2>
<div class="chart-container" id="chart5"></div>
<div class="chart-container" id="chart6"></div>
<div class="chart-container" id="chart7"></div>
<div class="chart-container" id="chart8"></div>
</section>
<section id="labour" class="section">
<h2 class="section-title">Labour Market</h2>
<div class="chart-container" id="chart9"></div>
<div class="chart-container" id="chart10"></div>
<div class="chart-container" id="chart11"></div>
<div class="chart-container" id="chart12"></div>
</section>
<section id="fiscal" class="section">
<h2 class="section-title">Fiscal</h2>
<div class="chart-container" id="chart13"></div>
<div class="chart-container" id="chart14"></div>
<div class="chart-container" id="chart15"></div>
<div class="chart-container" id="chart16"></div>
</section>
<section id="monetary" class="section">
<h2 class="section-title">Monetary</h2>
<div class="chart-container" id="chart17"></div>
<div class="chart-container" id="chart18"></div>
<div class="chart-container" id="chart19"></div>
<div class="chart-container" id="chart20"></div>
<div class="chart-container" id="chart21"></div>
</section>
</main>
</div>
<script>
// Function to update active category
function updateActiveCategory() {
const sections = document.querySelectorAll('.section');
const categories = document.querySelectorAll('.category');
// Get the current scroll position plus a small offset
const scrollPosition = window.scrollY + 300;
console.log(window.scrollY);
// Find which section is currently in view
sections.forEach((section) => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
const sectionId = section.id;
categories.forEach(category => {
if (category.dataset.category === sectionId) {
category.classList.add('active');
} else {
category.classList.remove('active');
}
});
}
});
}
// Add scroll event listener
window.addEventListener('scroll', updateActiveCategory);
// Add click handlers for category navigation
document.querySelectorAll('.category').forEach(category => {
category.addEventListener('click', () => {
const sectionId = category.dataset.category;
const section = document.getElementById(sectionId);
if (section) {
section.scrollIntoView({ behavior: 'smooth' });
}
});
});
// Load Vega-Lite charts
const charts = [
'C1_Population_Top21.json',
'C2_Fertility.json',
'C3_Migration.json',
'C4_PopulationDistribution_Tall.json',
'C5_GDPpc.json',
'C6_GDP_LongRun.json',
'C7_GDP_5yr.json',
'C7_GDP_10yr.json',
'C9_Unemployment.json',
'C10_YouthUnemployment.json',
'C11_Inequality.json',
'C12_MinimumWages.json',
'C13_TaxTake.json',
'C14_GovDeficit.json',
'C16_DebtCost.json',
'C16_GovDebt_Gross.json',
'C17_Inflation.json',
'C18_Bank_Rates.json',
'C19_PPP_BigMac.json',
'C20_CurrentAccount_GDP.json',
'C21_InvestmentPosition.json'
];
let path = 'charts/p21/';
// Load all charts and then initialize the intersection observer
Promise.all(charts.map((chart, index) =>
vegaEmbed(`#chart${index + 1}`, path + chart, {
actions: false,
theme: 'custom'
}).catch(console.error)
)).then(() => {
// After all charts are loaded, trigger an initial check
updateActiveCategory();
// Add a resize observer to handle dynamic height changes
const resizeObserver = new ResizeObserver(() => {
updateActiveCategory();
});
// Observe the main content area for size changes
resizeObserver.observe(document.querySelector('.main-content'));
});
</script>
</body>
</html>