Skip to content

Commit 756611d

Browse files
committed
improve chart text legibility on mobile
1 parent d63b2fc commit 756611d

3 files changed

Lines changed: 47 additions & 3 deletions

File tree

src/components/charts/HeatmapGrid.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
<div class="hg-wrap" bind:this={containerEl}>
178178
<svg
179179
class="hg-svg"
180+
width={W}
181+
height={H}
180182
viewBox="0 0 {W} {H}"
181183
preserveAspectRatio="xMidYMid meet"
182184
role="img"
@@ -398,9 +400,14 @@
398400
font-family: var(--sans);
399401
}
400402
401-
@media (max-width: 520px) {
403+
/* On narrow viewports we stop shrinking the SVG and let it scroll
404+
horizontally inside .hg-wrap. This keeps the in-chart text at its
405+
native ~12px instead of dropping to 7–9px after viewBox scaling,
406+
without risking row-label overlap from a font bump. */
407+
@media (max-width: 820px) {
402408
.hg-svg {
403-
min-width: 480px;
409+
width: auto;
410+
min-width: 100%;
404411
}
405412
}
406413

src/components/charts/LegendScatter.svelte

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
{/if}
203203
</text>
204204
<text
205-
class="axis-title"
205+
class="axis-title axis-title-y"
206206
transform="translate({-54},{ih / 2}) rotate(-90)"
207207
text-anchor="middle"
208208
>
@@ -371,6 +371,27 @@
371371
opacity: 0.9;
372372
}
373373
374+
/* viewBox is 760×420; on a ~440px-wide mobile card the SVG shrinks
375+
~0.58×, so the desktop sizes above render below the 80%-of-caption
376+
legibility floor (~11.5px). Bump them in SVG units to compensate.
377+
The rotated y-axis title would collide with the bigger y-tick labels
378+
in the cramped left margin, so we hide it on mobile — the chart
379+
description above already names the y dimension. */
380+
@media (max-width: 820px) {
381+
.tick {
382+
font-size: 18px;
383+
}
384+
.axis-title {
385+
font-size: 20px;
386+
}
387+
.axis-better {
388+
font-size: 22px;
389+
}
390+
.axis-title-y {
391+
display: none;
392+
}
393+
}
394+
374395
.backdrop-line {
375396
stroke: var(--text-muted);
376397
stroke-width: 1.4;

src/components/sections/findings/F2_StratifiedAdvantage.svelte

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,22 @@
315315
letter-spacing: 0.06em;
316316
}
317317
318+
/* The chart's viewBox is 760×380 — on a ~440px-wide mobile card the SVG
319+
shrinks by ~0.58×, so 12px in SVG coords renders as ~7px on screen.
320+
Bump tick labels to keep effective size ≥80% of the description
321+
(0.9rem ≈ 14.4px → ~11.5px target). The rotated y-axis title would
322+
collide with the bigger tick labels in the cramped left margin, so we
323+
hide it — the chart description above already names the metric. */
324+
@media (max-width: 820px) {
325+
.tick-label-y,
326+
.tick-label-x {
327+
font-size: 20px;
328+
}
329+
.axis-title {
330+
display: none;
331+
}
332+
}
333+
318334
.series-line {
319335
stroke-width: 3;
320336
opacity: 0.9;

0 commit comments

Comments
 (0)