Scale
ProRounds a domain out to clean tick steps (1, 2, 2.5, 5 × 10ⁿ).
Preview
It's types and helpers, listed below.
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/scale
Brings in: data
Functions
niceTicks(min: number, max: number, count = 5)Rounds a domain out to clean tick steps (1, 2, 2.5, 5 × 10ⁿ).
linear(d0: number, d1: number, r0: number, r1: number)compact(v: number)Compact from 1,000 up: 950 · 1.2K · 12K · 4.2M.
formatValue(v: number | null, format: ValueFormat = "number", full = false, number: NumberFormat = runtimeNumber)A value as a chart writes it: compact on axes and labels, in full (full) for tooltips and tables. number writes the full form; it defaults to the runtime's locale, so components pass useFormat().number to stay hydration-safe.
seriesColor(i: number)The categorical series colour for the nth series, in fixed order. Past 6, callers fold into "Other".
Types
- NumberFormat
- Writes a number in full, in the locale; charts pass `useFormat().number` so server and browser agree.
(n: number, options?: Intl.NumberFormatOptions) => string