Skip to content

Commit 08a7da9

Browse files
committed
fix: change sunbursts size, police and legend
1 parent 11d780f commit 08a7da9

2 files changed

Lines changed: 72 additions & 25 deletions

File tree

website/js/gender-evolution.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,16 @@
331331
.sort((a, b) => a - b)
332332
.filter(year => year <= STOP_YEAR);
333333

334-
state.currentYear = state.availableYears.includes(1896)
335-
? 1896
336-
: state.availableYears[0];
334+
const previousYear = state.currentYear;
335+
if (previousYear && state.availableYears.includes(previousYear)) {
336+
state.currentYear = previousYear;
337+
} else if (previousYear) {
338+
state.currentYear = state.availableYears.reduce((closest, y) =>
339+
Math.abs(y - previousYear) < Math.abs(closest - previousYear) ? y : closest
340+
);
341+
} else {
342+
state.currentYear = state.availableYears[0];
343+
}
337344

338345
updateSeasonButtons();
339346
updateSliderLimits();
@@ -507,11 +514,24 @@
507514
.join("text")
508515
.attr("transform", d => `translate(${arc.centroid(d)})`)
509516
.attr("text-anchor", "middle")
510-
.attr("font-family", "Arial, sans-serif")
517+
.attr("font-family", "'Elms Sans', sans-serif")
511518
.attr("font-size", 15)
512519
.attr("font-weight", 700)
513520
.attr("fill", "#111")
514521
.text(d => `${d.data.percent}%`);
522+
523+
const legend = container.append("div").attr("class", "gender-pie-legend");
524+
525+
[
526+
{ key: "women", label: "Women" },
527+
{ key: "men", label: "Men" }
528+
].forEach(({ key, label }) => {
529+
const item = legend.append("div").attr("class", "gender-pie-legend-item");
530+
item.append("span")
531+
.attr("class", "gender-pie-legend-swatch")
532+
.style("background-color", genderConfig[key].centerColor);
533+
item.append("span").text(label);
534+
});
515535
}
516536

517537
/* ============================================================
@@ -534,12 +554,12 @@
534554
.append("div")
535555
.attr("class", "gender-chart");
536556

537-
const width = 760;
538-
const height = 760;
557+
const width = 460;
558+
const height = 460;
539559

540-
const innerHole = 72;
541-
const sportRingThickness = 130;
542-
const disciplineRingThickness = 230;
560+
const innerHole = 45;
561+
const sportRingThickness = 82;
562+
const disciplineRingThickness = 118;
543563

544564
const root = d3.hierarchy(data)
545565
.sum(d => d.value || 0)
@@ -623,20 +643,20 @@
623643
.attr("transform", d =>
624644
labelTransform(d, innerHole, sportRingThickness, disciplineRingThickness)
625645
)
626-
.attr("font-family", "Arial, sans-serif")
627-
.attr("font-size", d => d.depth === 1 ? 15 : 11)
646+
.attr("font-family", "'Elms Sans', sans-serif")
647+
.attr("font-size", d => d.depth === 1 ? 11 : 9)
628648
.attr("font-weight", d => d.depth === 1 ? 700 : 400)
629649
.attr("fill", "#111");
630650

631651
labels.each(function (d) {
632652
const textEl = d3.select(this);
633653
const lines = splitLabelIntoLines(
634654
d.data.name,
635-
d.depth === 1 ? 16 : 18,
655+
d.depth === 1 ? 11 : 13,
636656
2
637657
);
638658

639-
const lineHeight = d.depth === 1 ? 1.05 : 0.95;
659+
const lineHeight = d.depth === 1 ? 0.95 : 0.85;
640660
const startDy = lines.length === 1 ? "0.35em" : "-0.15em";
641661

642662
lines.forEach((line, i) => {
@@ -652,7 +672,7 @@
652672
.append("text")
653673
.attr("text-anchor", "middle")
654674
.attr("dy", "0.35em")
655-
.attr("font-family", "Arial, sans-serif")
675+
.attr("font-family", "'Elms Sans', sans-serif")
656676
.attr("font-size", 17)
657677
.attr("font-weight", 700)
658678
.attr("fill", "#111")
@@ -699,11 +719,11 @@
699719
const angle = d.x1 - d.x0;
700720

701721
if (d.depth === 1) {
702-
return angle > 0.15;
722+
return angle > 0.22;
703723
}
704724

705725
if (d.depth === 2) {
706-
return angle > 0.04;
726+
return angle > 0.08;
707727
}
708728

709729
return false;

website/styles.css

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ p {
154154

155155
[data-anchor="gender"] {
156156
background: #000 !important;
157+
padding: 0 !important;
157158
}
158159

159160
[data-anchor="gender"] .container {
@@ -173,8 +174,7 @@ p {
173174
width: 100%;
174175
max-width: 1800px;
175176
margin: 0 auto;
176-
padding: 12px 24px 12px 24px;
177-
min-height: 760px;
177+
padding: 4px 24px 4px 24px;
178178
background: transparent;
179179
border: none;
180180
border-radius: 0;
@@ -190,6 +190,33 @@ p {
190190
margin-bottom: 10px;
191191
}
192192

193+
/* pie legend */
194+
.gender-pie-legend {
195+
display: flex;
196+
flex-direction: column;
197+
gap: 8px;
198+
margin-left: 18px;
199+
justify-content: center;
200+
}
201+
202+
.gender-pie-legend-item {
203+
display: flex;
204+
align-items: center;
205+
gap: 8px;
206+
font-family: "Elms Sans", sans-serif;
207+
font-size: 15px;
208+
color: white;
209+
}
210+
211+
.gender-pie-legend-swatch {
212+
display: inline-block;
213+
width: 18px;
214+
height: 18px;
215+
border-radius: 3px;
216+
border: 1px solid rgba(255,255,255,0.3);
217+
flex-shrink: 0;
218+
}
219+
193220
/* season buttons */
194221
.gender-controls {
195222
position: absolute;
@@ -208,7 +235,7 @@ p {
208235
background: #111;
209236
color: white;
210237
cursor: pointer;
211-
font-family: Arial, sans-serif;
238+
font-family: "Elms Sans", sans-serif;
212239
font-size: 18px;
213240
transition: 0.2s ease;
214241
}
@@ -240,7 +267,7 @@ p {
240267
}
241268

242269
.gender-chart-title {
243-
font-family: Arial, sans-serif;
270+
font-family: "Elms Sans", sans-serif;
244271
font-size: 28px;
245272
font-weight: 700;
246273
color: white;
@@ -280,7 +307,7 @@ p {
280307
min-width: 60px;
281308
text-align: center;
282309
color: white;
283-
font-family: Arial, sans-serif;
310+
font-family: "Elms Sans", sans-serif;
284311
font-size: 24px;
285312
font-weight: 700;
286313
}
@@ -296,7 +323,7 @@ p {
296323
border: 1px solid rgba(255,255,255,0.15);
297324
border-radius: 10px;
298325
padding: 10px 12px;
299-
font-family: Arial, sans-serif;
326+
font-family: "Elms Sans", sans-serif;
300327
font-size: 14px;
301328
line-height: 1.35;
302329
box-shadow: 0 6px 16px rgba(0,0,0,0.35);
@@ -305,7 +332,7 @@ p {
305332

306333
.gender-empty,
307334
.gender-error {
308-
font-family: Arial, sans-serif;
335+
font-family: "Elms Sans", sans-serif;
309336
color: white;
310337
font-size: 18px;
311338
text-align: center;
@@ -556,7 +583,7 @@ p {
556583

557584
.geo-popup-title {
558585
color: white;
559-
font-family: Arial, sans-serif;
586+
font-family: "Elms Sans", sans-serif;
560587
font-size: 24px;
561588
font-weight: 800;
562589
text-align: left;
@@ -565,7 +592,7 @@ p {
565592
.geo-popup-note {
566593
margin-top: 6px;
567594
color: #ffd166;
568-
font-family: Arial, sans-serif;
595+
font-family: "Elms Sans", sans-serif;
569596
font-size: 14px;
570597
line-height: 1.35;
571598
text-align: left;

0 commit comments

Comments
 (0)