Skip to content

Commit f2966e9

Browse files
committed
fix: timeline name country title and normallized titles across screens
1 parent e80277a commit f2966e9

4 files changed

Lines changed: 63 additions & 55 deletions

File tree

docs/country_timeline.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,14 +711,19 @@
711711
}
712712
.dc-title {
713713
font-family: 'Cormorant Garamond', serif;
714-
font-size: 54px;
714+
font-size: clamp(28px, 3.5vw, 54px);
715715
font-weight: 400;
716716
letter-spacing: 0.05em;
717717
color: var(--text);
718718
text-transform: uppercase;
719-
white-space: nowrap;
719+
white-space: normal;
720720
text-align: center;
721-
line-height: 1;
721+
line-height: 1.1;
722+
overflow-wrap: break-word;
723+
display: -webkit-box;
724+
-webkit-line-clamp: 2;
725+
-webkit-box-orient: vertical;
726+
overflow: hidden;
722727
}
723728
.dc-title em {
724729
font-style: italic;
@@ -876,7 +881,7 @@
876881
.hud-year .yr { font-size: 64px; }
877882
.hud-progress { right: 20px; bottom: 30px; width: 200px; }
878883
.dc-header { grid-template-columns: 1fr; gap: 8px; padding: 20px 20px 16px; }
879-
.dc-title { font-size: 38px; text-align: left; }
884+
.dc-title { font-size: clamp(22px, 6vw, 38px); text-align: left; }
880885
.dc-meta-group { justify-content: space-between; }
881886
.dc-body { grid-template-columns: 1fr; }
882887
.dc-vdivider { height: 1px; width: auto; }

docs/curators.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ <h2 class="name">Mercury<em> ☿</em></h2>
554554
<div class="humans">
555555
<div class="person"><span class="name-h">Luna Raithle</span><span class="sciper">SCIPER 332446</span></div>
556556
<div class="person"><span class="name-h">Morgane Magnin</span><span class="sciper">SCIPER 347041</span></div>
557-
<div class="person"><span class="name-h">Annaëlle Myriam Benlamri</span><span class="sciper">SCIPER 297135</span></div>
557+
<div class="person"><span class="name-h">Annaelle Myriam Benlamri</span><span class="sciper">SCIPER 297135</span></div>
558558
</div>
559559
<div class="meta">
560560
Made for <span style="color:var(--text-mid)">COM-480 · Data Visualization · EPFL · 2026</span><br>

docs/js/data.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ const DISASTER_TYPE_META = {
2929
storm: { label: 'Storm', color: '#8C86FF', order: 60 },
3030
epidemic: { label: 'Epidemic', color: '#6EE7C8', order: 70 },
3131
infestation: { label: 'Infestation', color: '#D6E75B', order: 80 },
32-
animal_incident: { label: 'Animal Incident', color: '#6DD6E8', order: 90 },
3332
volcano: { label: 'Volcano', color: '#FF695B', order: 100 },
3433
wildfire: { label: 'Wildfire', color: '#FFA142', order: 110 },
35-
impact: { label: 'Impact', color: '#C7A8FF', order: 120 }
3634
};
3735

3836
const DISASTER_COLORS = Object.fromEntries(
@@ -103,9 +101,55 @@ const COUNTRY_NAME_ALIASES = {
103101
'british indian ocean territory': 'BIOT'
104102
};
105103

104+
// Shared base: NFD decompose → strip diacritics → lowercase → collapse non-alpha to spaces
105+
function baseNormalize(str) {
106+
return String(str)
107+
.normalize('NFD')
108+
.replace(/[̀-ͯ]/g, '')
109+
.toLowerCase()
110+
.replace(/[^a-z0-9]+/g, ' ')
111+
.replace(/\s+/g, ' ')
112+
.trim();
113+
}
114+
115+
// Aliases used by the globe for feature-name → ISO matching (returns lowercase keys)
116+
const GLOBE_COUNTRY_NAME_ALIASES = {
117+
'bolivia plurinational state of': 'bolivia',
118+
'bosnia and herz': 'bosnia and herzegovina',
119+
'brunei darussalam': 'brunei',
120+
'cape verde': 'cabo verde',
121+
'central african rep': 'central african republic',
122+
'czech republic': 'czechia',
123+
'dem rep congo': 'democratic republic of the congo',
124+
'dominican rep': 'dominican republic',
125+
'eq guinea': 'equatorial guinea',
126+
'iran islamic republic of': 'iran',
127+
'ivory coast': 'cote d ivoire',
128+
'lao peoples democratic republic': 'laos',
129+
'macedonia': 'north macedonia',
130+
'micronesia federated states of': 'micronesia',
131+
'moldova': 'republic of moldova',
132+
'netherlands kingdom of the': 'netherlands',
133+
'north korea': 'democratic peoples republic of korea',
134+
'republic of congo': 'congo',
135+
'republic of korea': 'south korea',
136+
'russian federation': 'russia',
137+
's korea': 'south korea',
138+
's sudan': 'south sudan',
139+
'solomon is': 'solomon islands',
140+
'state of palestine': 'palestine',
141+
'swaziland': 'eswatini',
142+
'syrian arab republic': 'syria',
143+
'tanzania': 'united republic of tanzania',
144+
'turkiye': 'turkey',
145+
'united kingdom of great britain and northern ireland': 'united kingdom',
146+
'venezuela bolivarian republic of': 'venezuela',
147+
'viet nam': 'vietnam'
148+
};
149+
106150
function normalizeCountryName(raw) {
107151
if (!raw) return raw;
108-
const key = raw.toLowerCase().replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
152+
const key = baseNormalize(raw);
109153
if (COUNTRY_NAME_ALIASES[key]) return COUNTRY_NAME_ALIASES[key];
110154
// Title-case the original if no alias found
111155
return raw.replace(/\w\S*/g, w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase());

docs/js/scene2_globe.js

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,7 @@
22
SCENE 2: 3D GLOBE
33
============================================ */
44

5-
const GLOBE_COUNTRY_NAME_ALIASES = {
6-
'bolivia plurinational state of': 'bolivia',
7-
'bosnia and herz': 'bosnia and herzegovina',
8-
'brunei darussalam': 'brunei',
9-
'cape verde': 'cabo verde',
10-
'central african rep': 'central african republic',
11-
'czech republic': 'czechia',
12-
'dem rep congo': 'democratic republic of the congo',
13-
'dominican rep': 'dominican republic',
14-
'eq guinea': 'equatorial guinea',
15-
'iran islamic republic of': 'iran',
16-
'ivory coast': 'cote d ivoire',
17-
'lao peoples democratic republic': 'laos',
18-
'macedonia': 'north macedonia',
19-
'micronesia federated states of': 'micronesia',
20-
'moldova': 'republic of moldova',
21-
'netherlands kingdom of the': 'netherlands',
22-
'north korea': 'democratic peoples republic of korea',
23-
'republic of congo': 'congo',
24-
'republic of korea': 'south korea',
25-
'russian federation': 'russia',
26-
's korea': 'south korea',
27-
's sudan': 'south sudan',
28-
'solomon is': 'solomon islands',
29-
'state of palestine': 'palestine',
30-
'swaziland': 'eswatini',
31-
'syrian arab republic': 'syria',
32-
'tanzania': 'united republic of tanzania',
33-
'turkiye': 'turkey',
34-
'united kingdom of great britain and northern ireland': 'united kingdom',
35-
'venezuela bolivarian republic of': 'venezuela',
36-
'viet nam': 'vietnam'
37-
};
38-
39-
// ISO_ALIASES and canonicalIso() are defined in data.js (loaded first)
5+
// GLOBE_COUNTRY_NAME_ALIASES, baseNormalize(), canonicalIso() defined in data.js (loaded first)
406
const GLOBE_ISO_CENTER_ALIASES = ISO_ALIASES;
417

428
const GLOBE_FALLBACK_CENTERS = {
@@ -335,7 +301,7 @@ const Scene2 = {
335301
? getDisasterTypeLabel(this.selectedType)
336302
: 'No matching type';
337303
const accent = hasMatches ? getDisasterColor(this.selectedType) : '#97AEC4';
338-
const displayName = country?.properties?.name || stats.country;
304+
const displayName = normalizeCountryName(stats.country || country?.properties?.name);
339305

340306
return `
341307
<div style="background: rgba(13,17,23,0.95); padding: 12px; border-radius: 8px; border: 1px solid ${accent};">
@@ -445,15 +411,8 @@ const Scene2 = {
445411
},
446412

447413
normalizeCountryName(name = '') {
448-
const normalized = String(name)
449-
.normalize('NFD')
450-
.replace(/[\u0300-\u036f]/g, '')
451-
.toLowerCase()
452-
.replace(/[^a-z0-9]+/g, ' ')
453-
.replace(/\s+/g, ' ')
454-
.trim();
455-
456-
return GLOBE_COUNTRY_NAME_ALIASES[normalized] || normalized;
414+
const key = baseNormalize(name);
415+
return GLOBE_COUNTRY_NAME_ALIASES[key] || key;
457416
},
458417

459418
getInternalCountryCenter(feature) {
@@ -556,7 +515,7 @@ const Scene2 = {
556515
const color = this.selectedType === 'all' ? '#1E3A8A' : getDisasterColor(this.selectedType);
557516

558517
return countryGroups.map(({ iso, events: countryEvents, center }) => {
559-
const country = COUNTRY_STATS[iso]?.country || countryEvents[0]?.country || iso;
518+
const country = normalizeCountryName(COUNTRY_STATS[iso]?.country || countryEvents[0]?.country) || iso;
560519
const count = countryEvents.length;
561520
const deaths = d3.sum(countryEvents, d => d.deaths);
562521

@@ -923,7 +882,7 @@ const Scene2 = {
923882

924883
return {
925884
iso,
926-
country: stats.country,
885+
country: normalizeCountryName(stats.country),
927886
count: countryEvents.length,
928887
deaths: d3.sum(countryEvents, d => d.deaths),
929888
damage: d3.sum(countryEvents, d => d.damage)

0 commit comments

Comments
 (0)