Skip to content

Airdrop chart: fix diamond label clipping and MCap caption float formatting #1057

@realproject7

Description

@realproject7

Two visible bugs on the new chart from #1056

1. Diamond milestone label is clipped at the right edge

Visible on https://plotlink.xyz/airdrop right now: `unlocks 100%` shows as `unlocks 1` and the CMC rank `≈ #250` is also truncated.

Cause: SVG viewBox is 0 0 600 110 and pad.right = 16. Diamond's vertical line sits at x = 16 + 1.0 × (600 - 16 - 16) = 584. The labels use text-anchor="middle" centered at x=584, so half of unlocks 100% (≈35px wide on each side) extends past x=600 and gets clipped.

Fix: increase pad.right to ~50 so the diamond line moves leftward and labels fit. Also bump pad.left to ~24 so the $0 endpoint label has room.

2. Current MCap caption shows raw float

`Current: $33.523555869999996K`

Cause: formatMcap does n / 1_000 and template-literals the result without rounding.

Fix: round the K/M value to 2 decimals (when not integer):

function formatMcap(n: number): string {
  if (n >= 1_000_000) {
    const m = n / 1_000_000;
    return Number.isInteger(m) ? `$${m}M` : `$${m.toFixed(2)}M`;
  }
  if (n >= 1_000) {
    const k = n / 1_000;
    return Number.isInteger(k) ? `$${k}K` : `$${k.toFixed(2)}K`;
  }
  return `$${n.toFixed(0)}`;
}

Test cases:

  • formatMcap(1_000_000)$1M (integer kept clean)
  • formatMcap(33_523.555)$33.52K
  • formatMcap(50)$50

Files

  • src/components/airdrop/CampaignHero.tsx

Acceptance criteria

  • All four milestone labels visible in full on desktop including $100M / unlocks 100% / (≈ #250)
  • Current MCap caption shows $33.52K (or whatever the live value rounds to), not a long float
  • No layout regression — all other milestone labels still render correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions