From 86c4fb100891a7bd9f24a75a9829821038a14849 Mon Sep 17 00:00:00 2001 From: Flotapponnier Date: Tue, 15 Sep 2026 01:22:16 +0200 Subject: [PATCH] compare charts: accent on the selected view/range, hidden when either side has no data, isolated points drawn Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw --- src/components/compare-trend-chart.tsx | 45 ++++++++++++++++++--- src/components/perp-volume-head-to-head.tsx | 2 +- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/components/compare-trend-chart.tsx b/src/components/compare-trend-chart.tsx index 78694b6b..09330e73 100644 --- a/src/components/compare-trend-chart.tsx +++ b/src/components/compare-trend-chart.tsx @@ -7,6 +7,9 @@ import { lineColor } from "@/lib/series-colors"; type Range = "7d" | "30d" | "90d"; const RANGES: Range[] = ["7d", "30d", "90d"]; +/** Selected view / range pill: the site accent, so the active choice + * reads at a glance against the ink pills of the surrounding card. */ +const ACTIVE_PILL = "bg-accent text-white shadow-sm"; /** One selectable view: the bench headline metric or one of its panels. */ export type TrendView = { @@ -95,7 +98,9 @@ export function CompareTrendChart({ const b = pick(bSlug); const n = Math.max(a.length, b.length, payload.timestamps.length); if (n === 0) return null; - if (!a.some((v) => v !== null) && !b.some((v) => v !== null)) return null; + // Both sides must have at least one point: a one-sided chart reads + // as a comparison with a missing opponent, so the card hides it. + if (!a.some((v) => v !== null) || !b.some((v) => v !== null)) return null; return { a, b, ts: payload.timestamps, n }; }, [payload, aSlug, bSlug]); @@ -184,6 +189,12 @@ export function CompareTrendChart({ return idx.map((i) => ({ i, label: fmtTs(series.ts[i], range) })); }, [series, range]); + // Confirmed empty for the initial view/range: hide the block rather than + // show an empty frame. Once the user has interacted we keep the frame so + // the tabs stay reachable and say so inline. + const [touched, setTouched] = useState(false); + if (payload !== undefined && !series && !touched) return
; + return (
@@ -194,10 +205,13 @@ export function CompareTrendChart({