From 42d4854f9cd68e628c4d9df3f5ec4493e2da0e67 Mon Sep 17 00:00:00 2001 From: dahyeon Date: Mon, 8 Jun 2026 01:15:55 -0700 Subject: [PATCH] fix(web): center compact tier chart labels --- apps/web/src/components/TierHistoryChart.tsx | 99 ++++++++++++++------ 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/apps/web/src/components/TierHistoryChart.tsx b/apps/web/src/components/TierHistoryChart.tsx index 30e9e7f4..508361c8 100644 --- a/apps/web/src/components/TierHistoryChart.tsx +++ b/apps/web/src/components/TierHistoryChart.tsx @@ -52,6 +52,19 @@ const QUEUE_LABELS: Record = { RANKED_FLEX_SR: "자유랭크", }; +const TIER_COMPACT_NAMES: Record = { + IRON: "I", + BRONZE: "B", + SILVER: "S", + GOLD: "G", + PLATINUM: "P", + EMERALD: "E", + DIAMOND: "D", + MASTER: "M", + GRANDMASTER: "GM", + CHALLENGER: "C", +}; + type PeriodKey = "30" | "90" | "all"; type SummaryVariant = "footer" | "inline"; type SummaryDirection = "up" | "down" | "flat"; @@ -111,6 +124,20 @@ function formatTierLabel(entry: { return `${name}${rank ? ` ${rank}` : ""} · ${entry.leaguePoints ?? 0}LP`; } +function formatTierCompactLabel(entry: { + tier: string; + rank?: string; + leaguePoints?: number; +}) { + const tier = TIER_COMPACT_NAMES[entry.tier] ?? entry.tier; + const lp = entry.leaguePoints ?? 0; + if (APEX_TIERS.has(entry.tier)) { + return `${tier} ${lp}LP`; + } + const rank = normalizeRank(entry.rank); + return `${tier}${rank} ${lp}LP`; +} + function formatTierShort(tier: string) { return TIER_NAMES[tier] ?? tier; } @@ -146,6 +173,10 @@ type ChartPoint = { losses?: number; }; +function isSamePoint(left: ChartPoint, right: ChartPoint) { + return left.ts === right.ts && left.value === right.value; +} + function TierTooltip({ active, payload, @@ -252,6 +283,18 @@ export default function TierHistoryChart({ return { first, last, peak, direction }; }, [points]); + const xDomain = useMemo(() => { + if (summaryVariant !== "inline" || points.length < 2) { + return ["dataMin", "dataMax"] as const; + } + + const min = points[0].ts; + const max = points[points.length - 1].ts; + const span = Math.max(1, max - min); + const padding = Math.max(span * 0.08, 12 * 60 * 60 * 1000); + return [min - padding, max + padding] as const; + }, [points, summaryVariant]); + const header = (

@@ -336,7 +379,7 @@ export default function TierHistoryChart({ dataKey="ts" type="number" scale="time" - domain={["dataMin", "dataMax"]} + domain={xDomain} tickFormatter={formatDate} tick={{ fontSize: 10, fill: "currentColor" }} className="text-base-content/40" @@ -358,36 +401,23 @@ export default function TierHistoryChart({ /> {summaryVariant === "inline" && summary && ( <> - - - + {!isSamePoint(summary.peak, summary.last) && ( + + )} )}