# Scale

Rounds a domain out to clean tick steps (1, 2, 2.5, 5 × 10ⁿ).

- Registry name: `scale` (`@candor/scale`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/scale

## Install

```bash
npx candor-ui add scale
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/scale`.
It brings in: data.

## Functions

### niceTicks

```ts
niceTicks(min: number, max: number, count = 5)
```

Rounds a domain out to clean tick steps (1, 2, 2.5, 5 × 10ⁿ).

### linear

```ts
linear(d0: number, d1: number, r0: number, r1: number)
```

### compact

```ts
compact(v: number)
```

Compact from 1,000 up: 950 · 1.2K · 12K · 4.2M.

### formatValue

```ts
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

```ts
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.

```ts
(n: number, options?: Intl.NumberFormatOptions) => string
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
