StealThis .dev

Web3 — Portfolio Value Chart (PnL)

A wallet portfolio value card built around a hand-rolled SVG chart: a large animated count-up total in JetBrains Mono, absolute and percentage PnL that recolors green or red per range, and a smooth Catmull-Rom line with a gradient glow stroke over a fading area fill. Range tabs (1H / 1D / 1W / 1M / 1Y / ALL) regenerate a seeded mock series and replay a draw-in animation, while a crosshair tooltip tracks the pointer with the exact value and timestamp. An allocation bar and legend round out the card. No chart libraries — pure vanilla JS.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Portfolio Value Chart (PnL)

The card opens with the connected wallet (0x7a3f…c41d on the fictional Lumen Chain) and a big monospace portfolio total that counts up with an eased animation whenever the data changes. Directly under it, the PnL row shows the absolute move and the percentage for the selected window in a pill that flips between green and red — the arrow rotates to point the right way, and the “past week” / “past 24h” label updates with the range. Every value, address, and tick label is set in JetBrains Mono.

The chart itself is a hand-rolled SVG: each range tab (1H / 1D / 1W / 1M / 1Y / ALL) builds a deterministic random-walk series backwards from the same current value, projects it into the viewBox, and renders a Catmull-Rom-smoothed path with a purple-to-teal gradient stroke, a Gaussian-blur glow filter, and a gradient area fill underneath. Switching ranges replays a stroke-dashoffset draw-in while the fill fades up. Moving the pointer (or touching) over the chart snaps a dashed crosshair and halo dot to the nearest data point and floats a glassy tooltip with the value and formatted date, clamped so it never leaves the card.

The tablist supports arrow-key navigation with visible focus rings, a simulated Refresh button spins and re-draws the current range, and a tiny allocation footer breaks the portfolio into NOVA, LUM, stUSD, AETH, and Other with a segmented bar and glowing legend dots. The layout holds together down to 360px, where the tabs stretch full-width and the chart shortens, and prefers-reduced-motion collapses the animations.

UI-only simulation — no real wallet, RPC, or on-chain calls. Mock data, fictional tokens.