Skip to main content

Module fmt

Module fmt 

Source
Expand description

Small number-formatting helpers shared by the front-ends.

Functions§

axis_tokens
Tokens for an axis: 20M, 2.5M, 15k, 800 — no trailing zeros.
compact
1_234_567 → "1.23M", 12_345 → "12.3k", small numbers unchanged.
percent
A share as a whole percentage: 0.486 of the total → "49%".
short_label
A short x-axis label: drop the year (2026-05-10 → 05-10, 2026-05-10 13:00 → 13:00).
short_name
pi:Users-me-Projects-tokenburn → pi:tokenburn (last path-ish segment).
thousands
1234567 → "1,234,567".
usd
1.5 → "$1.50": cents, so small costs like $0.04 stay readable (the JSON output keeps the full precision).