From e62b68ede69fb75331be37e7b57ef13f873ac112 Mon Sep 17 00:00:00 2001 From: Tomas Horsky Date: Tue, 9 Jun 2026 16:18:37 +0900 Subject: [PATCH] small visual changes --- src/lib/world-map/StatsPanel.svelte | 76 ++++++++++++++++++++--------- src/lib/world-map/WorldMap.svelte | 2 +- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/lib/world-map/StatsPanel.svelte b/src/lib/world-map/StatsPanel.svelte index f96e17d..aa9050a 100644 --- a/src/lib/world-map/StatsPanel.svelte +++ b/src/lib/world-map/StatsPanel.svelte @@ -25,18 +25,37 @@ let grandTotal = $derived(Object.values(continentTotals).reduce((a, b) => a + b, 0)); let pct = $derived(grandTotal > 0 ? Math.round(total / grandTotal * 100) : 0); - let donutStyle = $derived.by(() => { - if (total === 0) return 'background: #e2e8f0'; + let segments = $derived.by(() => { + if (total === 0) return []; + const segs = []; let deg = 0; - const stops = []; for (const cont of CONTINENTS) { const angle = counts[cont] / total * 360; if (angle > 0) { - stops.push(`${continentColors[cont]} ${deg}deg ${deg + angle}deg`); + const startDeg = deg; + const endDeg = deg + angle; + const midDeg = (startDeg + endDeg) / 2; + const rad = (midDeg - 90) * Math.PI / 180; + const sr = (startDeg - 90) * Math.PI / 180; + const er = (endDeg - 90) * Math.PI / 180; + const cx = 90, cy = 90, outerR = 65, innerR = 30; + const x1 = cx + outerR * Math.cos(sr); + const y1 = cy + outerR * Math.sin(sr); + const x2 = cx + outerR * Math.cos(er); + const y2 = cy + outerR * Math.sin(er); + const x3 = cx + innerR * Math.cos(er); + const y3 = cy + innerR * Math.sin(er); + const x4 = cx + innerR * Math.cos(sr); + const y4 = cy + innerR * Math.sin(sr); + const largeArc = angle > 180 ? 1 : 0; + const path = `M ${x1} ${y1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2} L ${x3} ${y3} A ${innerR} ${innerR} 0 ${largeArc} 0 ${x4} ${y4} Z`; + const lx = cx + 82 * Math.cos(rad); + const ly = cy + 82 * Math.sin(rad); + segs.push({ cont, color: continentColors[cont], path, lx, ly, angle }); deg += angle; } } - return `background: conic-gradient(${stops.join(', ')})`; + return segs; }); @@ -64,9 +83,22 @@ {/each}
-
-
-
+ {#if segments.length > 0} + + {#each segments as seg} + + + {seg.cont} + + {/each} + + + {:else} + + + + + {/if}
@@ -177,22 +209,22 @@ margin: 24px 0; } - .donut { - width: 130px; - height: 130px; - border-radius: 50%; - display: flex; - align-items: center; - justify-content: center; - box-shadow: 0 2px 8px rgba(0,0,0,0.1); - outline: 2px solid #fff; + .donut-svg { + width: 160px; + height: 160px; + filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); } - .donut-hole { - width: 60px; - height: 60px; - border-radius: 50%; - background: #f8fafc; + .donut-label { + fill: #1f2937; + font-weight: 600; + pointer-events: none; + opacity: 0; + transition: opacity 0.15s ease; + } + + .seg-group:hover .donut-label { + opacity: 1; } .disclaimer { diff --git a/src/lib/world-map/WorldMap.svelte b/src/lib/world-map/WorldMap.svelte index 5cdfb52..cca1ed5 100644 --- a/src/lib/world-map/WorldMap.svelte +++ b/src/lib/world-map/WorldMap.svelte @@ -135,7 +135,7 @@ .datum(d) .attr('cx', cx) .attr('cy', cy) - .attr('r', 3) + .attr('r', 2) .attr('fill', getSelected().has(effId(d)) ? '#22c55e' : '#ffffff') .attr('stroke', '#94a3b8') .attr('stroke-width', 0.5);