A chart writes each number in three places: the value axis, the tooltip and the summary a screen reader hears. valueFormat and locale set all three at once, so the axis never says 1240000 while the tooltip says 1.24M.
- "number" writes 1240000 as 1,240,000, for counts.
- "compact" writes 1240000 as 1.2M, for big numbers on a small chart.
- "percent" writes 1240000 as 124,000,000%, for fractions (0.42 is 42%).
- { style: "currency", currency: "EUR" } writes 1240000 as €1,240,000.00, for money.
- { style: "unit", unit: "kilogram" } writes 1240000 as 1,240,000 kg, for measurements.
- (v) => v + " pts" writes 1240000 as 1240000 pts, for anything Intl can't write.
With no valueFormat, locale or series format at all, the axis prints plain digits (1240000) and the tooltip groups them (1,240,000). Set valueFormat="number" to group both.
Anything Intl.NumberFormat takes is an option: maximumFractionDigits, notation, signDisplay and the rest.
"percent" expects fractions. If your data already holds 42 for 42%, write { style: "unit", unit: "percent" } instead, which prints 42% without multiplying.
| week | Conversion |
|---|---|
| W1 | 2.1% |
| W2 | 2.4% |
| W3 | 2.3% |
| W4 | 3.1% |
| W5 | 3.4% |
locale is the language the numbers are written in, as a BCP 47 tag. It defaults to en-US on the server and in every browser, so the first HTML and the hydrated chart agree. Pass the reader's locale when you know it:
| month | Webshop | Bolt |
|---|---|---|
| jan. | 1 240 000 Ft | 880 000 Ft |
| febr. | 1 310 000 Ft | 910 000 Ft |
| márc. | 1 580 000 Ft | 860 000 Ft |
| ápr. | 1 720 000 Ft | 940 000 Ft |
The value axis widens to fit the longest label, so 1 950 000 Ft is not cut at the edge.
A locale the runtime doesn't know falls back to en-US instead of throwing.
series[].format overrides valueFormat for one series in the tooltip. Use it when one chart shows two kinds of number, such as orders and their average value. The axis keeps the chart's valueFormat, because there is only one axis.
Mixing units on one axis is usually a sign the chart wants to be two charts: see Choosing a chart.
stack="percent" writes the axis from 0% to 100% whatever valueFormat says, because the axis is a share. The tooltip keeps the real values in valueFormat, so the reader sees both "42%" on the axis and "1,240 orders" on hover.
Dates are written with date.format, a date-fns pattern:
The pattern is applied to ISO strings and Date objects on the axis, in the tooltip and in the summary. Month and day names are in English. For another language, write the text yourself in the row's label key, which every place that prints the x value uses as it is:
The charts are client components that render on the server, so you can fetch in a server component and pass the rows straight in. Props cross from the server to the client as data, and a function is not data: valueFormat={(v) => …} from a server component fails to render.
From a server component, use the string and Intl forms, which cover nearly everything. When you need a function, wrap the chart in a small client component and pass it the rows:
The same goes for date.onRangeChange.