fix: render share-card chart for single-bucket origins#1026
Closed
onchainlu wants to merge 1 commit into
Closed
Conversation
A brand-new / low-activity origin (e.g. ClaudeLines: 3 txns, $0.45, 3 buyers) has all its activity in one materialized bucket, so the bucketed stats query returns a single data point. The share card rendered (dataReady checks length > 0) but AreaChart bailed on length < 2, so every metric — volume, buyers, transactions — showed labels with no line. - AreaChart: draw a flat line for a single point instead of returning null - Scale the y-axis to the data's real peak (Math.max(...) || 1) so fractional volume values no longer get squished to the bottom edge Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the origin Share this page modal, the chart area renders labels but no line — for every metric (Volume, Buyers, Transactions). Reported on the ClaudeLines origin (3 txns, $0.45, 3 buyers).
Root cause
The modal's
AreaChart(a hand-rolled SVG inscreenshot-card.tsx) bails out withif (data.length < 2) return null. The card itself renders wheneverdataReady = stats && chartData.length > 0— so with a single data point (1 > 0true), the card shows stats/labels butAreaChartdraws nothing.A single point is the norm for new/low-activity origins: the share modal queries
stats.bucketedat the AllTime timeframe, which readsrecipient_stats_bucketed_0d— a materialized view bucketed at 1-day granularity with no gap-fill. Verified against prod: ClaudeLines' recipient has exactly one row in that MV:Secondary issue: the y-axis floor
Math.max(...data, 1)was written for integer counts. For fractional volume (dollars, often < 1) it squished the line to the bottom edge, so even with ≥2 buckets the volume line looked absent.Fix
screenshot-card.tsxAreaChart:data.length === 0. For a single point, duplicate it so the path spans the full width and renders a flat line instead of nothing.Math.max(...series) || 1) so fractional volume values aren't pinned to the bottom.Scope is intentionally the one component that had the bug. Every other chart in the app uses the shared recharts components (no
length < 2guard), so they already render single-bucket origins fine — confirmed, not affected.Out of scope
Server-side gap-fill / honoring
numBucketsingetBucketedStatisticsMV. It's shared by ~15 chart surfaces (broad blast radius) and — because the AllTime MV is 1-day granularity — wouldn't improve a 2-day-old origin like ClaudeLines beyond the flat line here. Tracked as a separate consideration (finer AllTime bucket resolution is the real lever, an MV redesign).Verification
pnpm exec eslint <file> --max-warnings 0→ cleanpnpm exec prettier --check <file>→ cleantsc --noEmit→ no new errors in the changed file (pre-existing repo errors are unrelated missing generated-DB module decls in a fresh worktree)chartData.length === 1Not exercised: live browser render of the modal (needs the running app against prod data); the fix is a pure client-render change validated statically + at the data layer.