fix(mail): legend takes natural width inside card + bar-chart always trims to hit-range

1. Legend-Wrapper: feste 180px-Width raus, stattdessen flex:1 + minWidth:0.
   Mit Donut 200px + gap 20 + Card-paddingHorizontal 16+16 wäre 200+20+180+32=432
   zu breit — kleine iPhones haben effektive Card-Width <380px. Legend ragte
   raus. Jetzt: Legend nimmt verfügbaren Rest-Platz, Texte trunken bei Bedarf.

2. useMailConnectionStats: zoom IMMER wenn nonEmpty.length > 0, nicht nur
   bei sparse-data-Bedingung. Bei 30-Tage-Range mit 1 Hit wurde das vorher
   trotzdem als 30 leere Bars + 1 Bar gerendert (Logik nonEmpty*3<raw greift
   zwar mathematisch, aber nicht aggressiv genug für wirklichen Visual-Fix).
   Jetzt: trim ALWAYS auf [firstHit..lastHit] — bei 1 Hit = 1 Bar, bei 5 Hits
   über 10 Tage = 10 Bars (5 mit Daten, 5 dazwischen). Konsistent visuell.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
chahinebrini 2026-05-14 00:53:08 +02:00
parent b47ac2427e
commit 55cba9a3fe
2 changed files with 6 additions and 5 deletions

View File

@ -112,7 +112,7 @@ export function MailDistributionChart({ data, hero, totalBlocked, isLegend }: Pr
centerLabel={centerLabel} centerLabel={centerLabel}
width={DONUT_WIDTH} width={DONUT_WIDTH}
/> />
<View style={{ gap: 6, width: 180 }}> <View style={{ gap: 6, flex: 1, minWidth: 0 }}>
{slices.map((slice) => ( {slices.map((slice) => (
<LegendRow key={slice.label} slice={slice} colors={colors} /> <LegendRow key={slice.label} slice={slice} colors={colors} />
))} ))}

View File

@ -73,10 +73,11 @@ export function useMailConnectionStats(
data = aggregateToWeeks(raw); data = aggregateToWeeks(raw);
} else if (granularity === 'month') { } else if (granularity === 'month') {
data = aggregateToMonths(raw); data = aggregateToMonths(raw);
} else if (nonEmpty.length > 0 && nonEmpty.length * 3 < raw.length) { } else if (nonEmpty.length > 0) {
// Sparse data (z.B. nur 1-2 Tage von 30): zoom in auf die echte Range // IMMER auf die echte Hit-Range zoomen — von erstem nonEmpty bis
// zwischen erstem und letztem Hit. Vermeidet 30 leere Bars + 1 Bar // letztem nonEmpty. Gaps dazwischen bleiben sichtbar (für realistische
// ganz rechts wie bei einer frischen Outlook-Connection. // Verteilung), aber 29 leere Slots am Anfang + 1 Bar am Ende wird
// auf z.B. 1-3 Bars geschrumpft. Trim eliminiert das visuelle Rauschen.
const firstDate = nonEmpty[0].date; const firstDate = nonEmpty[0].date;
const lastDate = nonEmpty[nonEmpty.length - 1].date; const lastDate = nonEmpty[nonEmpty.length - 1].date;
data = raw.filter((e) => e.date >= firstDate && e.date <= lastDate); data = raw.filter((e) => e.date >= firstDate && e.date <= lastDate);