Token usage chartPro
Daily tokens as an area with the cached share as a line: hover any day for its numbers, switch the range and the totals roll.
oxyn add token-usage-chartThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Daily tokens as an area with the cached share as a dashed line (spark_path).
- Hovering a day or arrowing through the plot draws a rule and a tooltip with the date, Tokens and Cached.
- Range buttons (30d, 90d, All) re-window the plot, the date line and the totals: Total usage, Avg. daily usage and Est. cost (usage_totals: uncached tokens at per_m_cents a million, cached at a tenth), which roll to their new values.
When not to use
- A launch countdown with digits that roll per unit, a compact one-line variant, hours absorbing days when days are hidden, and a live state with a pulsing dot at zero: use Countdown instead.
- A total that moves clearly: use Animated counter instead.
- A collapsible JSON tree with search, paging for long arrays, copy value or path, the current path under the tree and full keyboard moves: use JSON viewer instead.
Installation
Token usage chart is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add token-usage-chartUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Quarter
Three months, three ranges.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Short
Two weeks of data.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
TokenUsageChart
| Prop | Type | Default | Description |
|---|---|---|---|
daysrequired | Vec<UsageDay> | — | Days, oldest first; the last is today. |
start | (i32, u32) | (2026, 177) | Year and day of the year of the first day (for the date labels). |
per_m_cents | f64 | 300.0 | Price of a million uncached tokens, cents. |
title | String | "Token usage" | Title. |
ranges | Vec<usize> | vec![30, 90, 0] | Range options in days (0 = all). |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| ←or→ | Read the previous / next day |
| Esc | Hide the tooltip |
Accessibility
- The plot is one focusable image with the totals in its label; the day tooltip is role=status.
- Range buttons are aria-pressed toggles.
From the spec
- The plot is one focusable image with totals in its label; the tooltip is role=status; range buttons are aria-pressed.
Motion & interaction
Timing
- Plot fade 350 ms; totals roll 260 ms; tooltip 120 ms.
- Reduced motion: no fade or roll.
Responsive behaviour
- Fills its card up to 420 px; the area stretches, strokes stay 1.5 px.
Edge cases (spec)
- Up to 420 px; the area stretches and strokes stay 1.5 px (non-scaling).
Notes for AI
- Import
TokenUsageChartfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
TokenUsageChartElinoxyn_gpui. - Props to set first:
days. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.