Chart
A dependency-free plotting primitive for trends, funnels, pies, horizontal and Likert bars, scatter and bubble plots, and dumbbells. Compose the named parts into one measured SVG; the legend focuses and toggles series, and every hue re-themes.
| week | Web | iOS | Android |
|---|---|---|---|
| Jul 7 | 1,840 | 1,210 | 760 |
| Jul 14 | 1,920 | 1,260 | 790 |
| Jul 21 | 1,880 | 1,300 | 780 |
| Jul 28 | 2,050 | 1,280 | 820 |
| Aug 4 | 2,010 | 1,350 | 850 |
| Aug 11 | 2,180 | 1,410 | 840 |
| Aug 18 | 2,140 | 1,390 | 880 |
| Aug 25 | 2,460 | 1,580 | 1,010 |
| Sep 1 | 2,520 | 1,620 | 1,040 |
| Sep 8 | 2,480 | 1,650 | 1,020 |
| Sep 15 | 2,610 | 1,700 | 1,080 |
| Sep 22 | 2,690 | 1,760 | 1,110 |
| Sep 29 | 1,120 | 740 | 470 |
Try it yourself. This one is live, and its code is right below.
| week | Web | iOS | Android |
|---|---|---|---|
| Jul 7 | 1,840 | 1,210 | 760 |
| Jul 14 | 1,920 | 1,260 | 790 |
| Jul 21 | 1,880 | 1,300 | 780 |
| Jul 28 | 2,050 | 1,280 | 820 |
| Aug 4 | 2,010 | 1,350 | 850 |
| Aug 11 | 2,180 | 1,410 | 840 |
| Aug 18 | 2,140 | 1,390 | 880 |
| Aug 25 | 2,460 | 1,580 | 1,010 |
| Sep 1 | 2,520 | 1,620 | 1,040 |
| Sep 8 | 2,480 | 1,650 | 1,020 |
| Sep 15 | 2,610 | 1,700 | 1,080 |
| Sep 22 | 2,690 | 1,760 | 1,110 |
| Sep 29 | 1,120 | 740 | 470 |
Installation#
Usage#
Chart is composed from named parts, like Card. The root takes the data, an optional index key for category labels, and a config that names each series’ label and color. The parts (ChartGrid, ChartArea, ChartLine, ChartTooltip) read it from context and draw into one shared, pixel-measured SVG.
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
import {
Chart,
ChartLegend,
ChartGrid,
ChartXAxis,
ChartYAxis,
ChartArea,
ChartLine,
ChartReferenceLine,
ChartAnnotation,
ChartTooltip,
} from "@/components/ui/chart"
<Chart>
<ChartLegend />
<ChartGrid />
<ChartXAxis />
<ChartYAxis />
<ChartArea />
<ChartLine />
{/* or ChartBar, ChartBars, ChartAreas, ChartFunnel, ChartPie, ChartDumbbell */}
<ChartReferenceLine />
<ChartAnnotation />
<ChartTooltip />
</Chart>
// Parts that draw their own axes and tooltip (the cartesian chrome stands down):
<Chart>
<ChartLegend />
<ChartBarsHorizontal />
{/* or ChartScatter */}
</Chart>Load animation#
Every chart plays a one-shot reveal the first time it mounts: the ChartLine self-draws left to right, the ChartArea fill rises from the baseline, and each ChartBar grows up from the zero line in a left-to-right cascade. It fires once, never on hover or re-sort, and honors prefers-reduced-motion (every layer simply appears drawn). Pass animate={false} on the Chart root to opt out. Press Replay to watch it again.
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
| month | Orders |
|---|---|
| Jan | 240 |
| Feb | 198 |
| Mar | 312 |
| Apr | 277 |
| May | 388 |
| Jun | 305 |
| Jul | 372 |
| Aug | 410 |
Line#
Layer a ChartLine per series; each resolves its hue from config, or takes an explicit color. The shared ChartTooltip lists every series at the hovered category, and a crosshair tracks the active point.
| month | Desktop | Mobile |
|---|---|---|
| Jan | 2,400 | 1,800 |
| Feb | 2,900 | 2,100 |
| Mar | 2,200 | 2,600 |
| Apr | 3,400 | 2,300 |
| May | 3,100 | 3,200 |
| Jun | 4,200 | 2,900 |
| Jul | 3,800 | 3,600 |
| Aug | 4,600 | 4,100 |
Area#
ChartArea fills the space under the trend with a currentColor gradient that fades to the baseline, so the wash is just the series hue at low opacity: a blue line yields a soft blue-100/200 fill. Pair it with a ChartLine for a crisp edge.
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
Smooth curves#
Pass curve="monotone" to ChartLine, ChartArea or ChartAreas to join the points with a monotone cubic instead of straight segments. It is smooth, yet it still passes through every point and never swings above a peak or below a trough the data does not have: a plateau stays flat and an extreme sits exactly on its point, so the curve never invents a value. Gaps, stacking, dashed, markEnd, the draw-in and the hover dot all follow the curve. Set the same curve on the area and the line drawn over it.
linear (default)
| month | Sessions |
|---|---|
| Jan | 420 |
| Feb | 480 |
| Mar | 480 |
| Apr | 610 |
| May | 440 |
| Jun | 520 |
| Jul | 520 |
| Aug | 700 |
monotone
| month | Sessions |
|---|---|
| Jan | 420 |
| Feb | 480 |
| Mar | 480 |
| Apr | 610 |
| May | 440 |
| Jun | 520 |
| Jul | 520 |
| Aug | 700 |
Missing data#
A point with a non-numeric (or absent) value is a gap. By default the ChartLine and ChartArea break at the gap, so a dropout reads honestly. Pass connectNulls to bridge across it instead.
Default: line breaks at gaps
| day | Signal |
|---|---|
| Mon | 40 |
| Tue | 52 |
| Wed | |
| Thu | 48 |
| Fri | 61 |
| Sat | |
| Sun | 70 |
connectNulls: bridged
| day | Signal |
|---|---|
| Mon | 40 |
| Tue | 52 |
| Wed | |
| Thu | 48 |
| Fri | 61 |
| Sat | |
| Sun | 70 |
Bar#
ChartBar draws a bar per category from a 0-anchored baseline. Each bar stands square on the baseline and rounds only at its value end (the bottom, for a negative bar), and ChartGrid draws the zero line a step stronger, so the bars stand on a floor. Hovering a column brings it forward and dims the rest, so the active value reads at a glance.
| month | Orders |
|---|---|
| Jan | 240 |
| Feb | 198 |
| Mar | 312 |
| Apr | 277 |
| May | 388 |
| Jun | 305 |
| Jul | 372 |
| Aug | 410 |
Value labels & highlight#
Pass label to ChartBar to print each value just past its bar end. It returns inline content, so a figure can carry a glyph. To single one datum out, draw the series in neutral (the foreground at 10% on every theme) and pass its index to highlight, so that one bar takes full ink. Hovering a column also lifts its x-axis tick to the foreground.
| week | Revenue |
|---|---|
| Week 1 | 18,484 |
| Week 2 | 21,489 |
| Week 3 | 24,941 |
| Week 4 | 19,994 |
Highlight & active bar#
highlight on ChartBar paints chosen bars in highlightColor (primary, full ink, by default) and leaves the rest in the series hue: an index for today, a list, a predicate over the row, or "active" for the bar under the pointer. The chart reports that bar through onActiveIndexChange (and takes a controlled activeIndex), so a legend or a headline can follow it. Here the latest month is lit until another is hovered. Swapping the highlight recolors the bars in place, so the grow-in never replays, and the tooltip swatch takes the hue the bar is wearing. While a column is hovered the others dim, except neutral bars: already faint, they hold their ink and the hovered one steps up instead, so no bar ever disappears.
Today in full ink
| day | Orders |
|---|---|
| Mon | 42 |
| Tue | 51 |
| Wed | 47 |
| Thu | 58 |
| Fri | 63 |
| Sat | 38 |
| Sun | 45 |
Follows the pointer
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
Grouped & stacked bars#
ChartBars draws several bar series in one band. By default they render grouped side by side; set stack on Chart to stack them, and the y-axis grows to the per-category total automatically. Grouped and stacked series alike take the categorical order, since each one is a different thing; opt into palette="tonal" only when the series are ordered steps of one measure. A color in config always wins.
Grouped
| month | Desktop | Mobile |
|---|---|---|
| Jan | 2,400 | 1,800 |
| Feb | 2,900 | 2,100 |
| Mar | 2,200 | 2,600 |
| Apr | 3,400 | 2,300 |
| May | 3,100 | 3,200 |
| Jun | 4,200 | 2,900 |
| Jul | 3,800 | 3,600 |
| Aug | 4,600 | 4,100 |
Stacked
| month | Desktop | Mobile |
|---|---|---|
| Jan | 2,400 | 1,800 |
| Feb | 2,900 | 2,100 |
| Mar | 2,200 | 2,600 |
| Apr | 3,400 | 2,300 |
| May | 3,100 | 3,200 |
| Jun | 4,200 | 2,900 |
| Jul | 3,800 | 3,600 |
| Aug | 4,600 | 4,100 |
Stacked area#
ChartAreas stacks several area series into a band chart when stack is set on Chart: each series sits on the cumulative total below it as a translucent band under its own edge line. Series that name no color take the categorical order; pass palette="tonal" for a one-hue ramp when the bands are ordered tiers of one measure. Without stack the series overlap from the baseline.
| month | Desktop | Mobile |
|---|---|---|
| Jan | 2,400 | 1,800 |
| Feb | 2,900 | 2,100 |
| Mar | 2,200 | 2,600 |
| Apr | 3,400 | 2,300 |
| May | 3,100 | 3,200 |
| Jun | 4,200 | 2,900 |
| Jul | 3,800 | 3,600 |
| Aug | 4,600 | 4,100 |
Legend#
Put ChartLegend inside the Chart and it keys the chart’s own series, sits above the plot (or below it, with placement="bottom") and becomes the chart’s control surface, as in Mixpanel. Hover a key and its series comes forward while the rest recede; click it to hide or show the series, and the scale and the stack refit around what is left; Alt+click shows it alone. The last series showing never hides. Past max keys, the rest fold into a +N more menu with the same controls.
| month | Organic | Paid search | Social | Referral | Partners | |
|---|---|---|---|---|---|---|
| Mar | 42 | 31 | 18 | 14 | 9 | 6 |
| Apr | 45 | 29 | 21 | 15 | 10 | 7 |
| May | 51 | 34 | 19 | 17 | 12 | 7 |
| Jun | 48 | 38 | 24 | 16 | 11 | 9 |
| Jul | 56 | 36 | 27 | 19 | 13 | 10 |
| Aug | 61 | 41 | 25 | 21 | 15 | 12 |
| Sep | 67 | 44 | 30 | 22 | 17 | 13 |
Outside a chart, ChartLegend is a plain key: feed it the same config (or explicit items) and each swatch resolves its hue exactly like the chart, palette fallback included.
| month | Desktop | Mobile |
|---|---|---|
| Jan | 2,400 | 1,800 |
| Feb | 2,900 | 2,100 |
| Mar | 2,200 | 2,600 |
| Apr | 3,400 | 2,300 |
| May | 3,100 | 3,200 |
| Jun | 4,200 | 2,900 |
| Jul | 3,800 | 3,600 |
| Aug | 4,600 | 4,100 |
Give an item a value and it prints after the label in the foreground, so the key doubles as a summary of each series. Inside a chart, value="sum", "average" or "last" summarises each series from the data, in its own format.
Driving it from outside#
The series state is controllable, so a table under the chart can run it, the way Mixpanel pairs every insight with its breakdown. hiddenSeries with onHiddenSeriesChange takes the checkboxes, and focusedSeries with onFocusedSeriesChange lights the plan under the pointer. A series and the period it is compared against always stay lit together.
| month | Enterprise | Pro | Business | Starter |
|---|---|---|---|---|
| Apr | 51,200 | 42,100 | 36,800 | 18,400 |
| May | 51,200 | 44,600 | 38,900 | 19,100 |
| Jun | 58,900 | 47,300 | 41,200 | 18,800 |
| Jul | 58,900 | 49,800 | 42,600 | 20,300 |
| Aug | 64,400 | 53,900 | 45,100 | 21,200 |
| Sep | 71,300 | 57,400 | 47,800 | 21,900 |
| Shown | Plan | Sep MRR | Since Apr |
|---|---|---|---|
| Enterprise | $71,300 | +39.3% | |
| Pro | $57,400 | +36.3% | |
| Business | $47,800 | +29.9% | |
| Starter | $21,900 | +19.0% |
Two measures & per-series format#
Two metrics at different magnitudes, like revenue and order count, get two charts stacked on one x-axis rather than a second y-axis. A dual axis lets the reader pair any two scales, so where the lines cross and how steep they look is an artefact of where each axis was set. Give both charts the same left padding so the plots align, and share activeIndex so hovering a month lights it in both. Each series also carries its own format, so the tooltip shows currency for revenue and a plain count for orders. (axis: "right" still works but is deprecated.)
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
| month | Orders |
|---|---|
| Jan | 240 |
| Feb | 198 |
| Mar | 312 |
| Apr | 277 |
| May | 388 |
| Jun | 305 |
| Jul | 372 |
| Aug | 410 |
Forecast & end marker#
ChartLine takes dashed for projected data and markEnd to pin a filled dot on the last point (a “current value” marker). Split actuals and projection into two series that share the seam point, and the solid line meets its dashed continuation cleanly.
| month | Actual | Projected |
|---|---|---|
| Jan | 4,200 | |
| Feb | 4,600 | |
| Mar | 5,100 | |
| Apr | 4,800 | |
| May | 5,600 | |
| Jun | 6,100 | 6,100 |
| Jul | 6,700 | |
| Aug | 7,200 |
Incomplete period#
Today’s count is still climbing, so drawn like a finished day it reads as a collapse. Pass partial on Chart (or a number, for several trailing periods) and the open period draws as provisional, Mixpanel’s treatment: a line dashes from the last complete point on the exact same curve, its area fades, a bar hatches, and the tooltip marks the period with partialLabel.
| day | Active users |
|---|---|
| Sep 16 | 3,120 |
| Sep 17 | 3,260 |
| Sep 18 | 3,190 |
| Sep 19 | 3,380 |
| Sep 20 | 2,840 |
| Sep 21 | 2,610 |
| Sep 22 | 3,290 |
| Sep 23 | 3,440 |
| Sep 24 | 3,510 |
| Sep 25 | 3,470 |
| Sep 26 | 3,620 |
| Sep 27 | 3,010 |
| Sep 28 | 2,790 |
| Sep 29 | 1,460 |
| day | Orders |
|---|---|
| Sep 16 | 212 |
| Sep 17 | 238 |
| Sep 18 | 224 |
| Sep 19 | 251 |
| Sep 20 | 188 |
| Sep 21 | 171 |
| Sep 22 | 243 |
| Sep 23 | 262 |
| Sep 24 | 259 |
| Sep 25 | 271 |
| Sep 26 | 284 |
| Sep 27 | 203 |
| Sep 28 | 186 |
| Sep 29 | 97 |
Compare to previous period#
Name the earlier period in a series’ config with compare and the pair reads as one story. The earlier series becomes a ghost: it borrows the hue, takes no palette slot, and its ChartLine draws thin, faint and dashed with no prop set. The tooltip prints the change beside the current value, green up and red down; give a down-is-good metric (churn, refunds, latency) inverted and the colors flip. In ChartBars the ghost stands beside its partner, faint.
| week | This quarter | Last quarter |
|---|---|---|
| W1 | 48,200 | 41,800 |
| W2 | 51,600 | 44,100 |
| W3 | 49,300 | 45,600 |
| W4 | 55,800 | 43,900 |
| W5 | 58,100 | 47,200 |
| W6 | 54,700 | 49,800 |
| W7 | 61,200 | 48,600 |
| W8 | 63,900 | 51,300 |
| W9 | 60,400 | 53,700 |
| W10 | 66,800 | 52,100 |
| W11 | 69,500 | 55,400 |
| W12 | 72,300 | 57,900 |
Reference lines#
ChartReferenceLine draws a horizontal threshold (y) or vertical marker (x) across the plot, with an optional label. Compose it after the data so it annotates on top, for a target, limit, or average. It defaults to a muted dashed line; pass a color to emphasize it.
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
Annotations#
ChartAnnotation pins a note to a category: a launch, an outage, a release, so the jump in the line explains itself. Its marker sits in a lane above the plot (the plot steps down to make room on its own) with a faint rule down to the baseline, and hovering it opens the note. Mixpanel numbers its markers; pass any short label, or none for a dot, and a color for a note that is bad news. The text also reaches screen readers beside the data table.
| day | Signups |
|---|---|
| Sep 1 | 420 |
| Sep 2 | 443 |
| Sep 3 | 462 |
| Sep 4 | 475 |
| Sep 5 | 481 |
| Sep 6 | 479 |
| Sep 7 | 471 |
| Sep 8 | 460 |
| Sep 9 | 450 |
| Sep 10 | 803 |
| Sep 11 | 613 |
| Sep 12 | 450 |
| Sep 13 | 464 |
| Sep 14 | 484 |
| Sep 15 | 507 |
| Sep 16 | 529 |
| Sep 17 | 408 |
| Sep 18 | 560 |
| Sep 19 | 564 |
| Sep 20 | 561 |
| Sep 21 | 552 |
| Sep 22 | 541 |
| Sep 23 | 601 |
| Sep 24 | 595 |
| Sep 25 | 596 |
| Sep 26 | 605 |
| Sep 27 | 620 |
| Sep 28 | 641 |
| Sep 29 | 664 |
Tooltip rows#
footer on ChartTooltip adds rows under the series, below a hairline, for a figure the chart does not draw: here the net of income and expenses. Build each row with ChartTooltipItem (a swatch, a label, a value) so it lines up with the rows above and its swatch keeps its hue in the portaled bubble. labelFormatter receives the whole row and its index after the label, so the heading can say more than the axis (a full month name).
| month | Income | Expenses |
|---|---|---|
| Mar | 51,200 | 38,400 |
| Apr | 48,600 | 41,200 |
| May | 56,300 | 39,800 |
| Jun | 53,900 | 44,100 |
| Jul | 61,500 | 42,700 |
| Aug | 58,800 | 45,300 |
Tooltip order & totals#
With several series, the tooltip reads best as a ranking. sort="desc" orders the rows by their value at the hovered category, so the leader comes first however the lines cross (a comparison row stays under its series). total adds the column’s sum below a hairline (a string names it), and maxItems folds the tail into a +N more line. While a legend key holds the focus, the other rows recede with their series.
| week | North America | EMEA | APAC | LATAM | Other |
|---|---|---|---|---|---|
| Aug 4 | 412 | 356 | 241 | 188 | 62 |
| Aug 11 | 438 | 371 | 259 | 176 | 58 |
| Aug 18 | 401 | 392 | 248 | 201 | 71 |
| Aug 25 | 466 | 418 | 277 | 214 | 66 |
| Sep 1 | 452 | 441 | 290 | 229 | 74 |
| Sep 8 | 489 | 437 | 311 | 236 | 69 |
| Sep 15 | 503 | 462 | 305 | 248 | 81 |
| Sep 22 | 521 | 488 | 332 | 259 | 77 |
Axis labels that fit#
interval="auto" on ChartXAxis measures its labels against the plot’s width and skips just enough of them that none collide, re-thinning as the chart resizes. It counts back from the last category, so the latest day or month always carries its name. minTickGap sets the clear space between labels (12px), and minInterval keeps a month of days reading by the week however wide the plot. A number still labels every Nth category from the first.
Wide
| day | Visits |
|---|---|
| Aug 29 | 1,200 |
| Aug 30 | 1,297 |
| Aug 31 | 1,385 |
| Sep 1 | 1,455 |
| Sep 2 | 1,501 |
| Sep 3 | 1,519 |
| Sep 4 | 1,508 |
| Sep 5 | 1,472 |
| Sep 6 | 1,415 |
| Sep 7 | 1,345 |
| Sep 8 | 1,270 |
| Sep 9 | 1,202 |
| Sep 10 | 1,147 |
| Sep 11 | 1,114 |
| Sep 12 | 1,108 |
| Sep 13 | 1,131 |
| Sep 14 | 1,181 |
| Sep 15 | 1,254 |
| Sep 16 | 1,343 |
| Sep 17 | 1,441 |
| Sep 18 | 1,537 |
| Sep 19 | 1,623 |
| Sep 20 | 1,690 |
| Sep 21 | 1,731 |
| Sep 22 | 1,745 |
| Sep 23 | 1,731 |
| Sep 24 | 1,691 |
| Sep 25 | 1,631 |
| Sep 26 | 1,560 |
| Sep 27 | 1,486 |
Narrow
| day | Visits |
|---|---|
| Aug 29 | 1,200 |
| Aug 30 | 1,297 |
| Aug 31 | 1,385 |
| Sep 1 | 1,455 |
| Sep 2 | 1,501 |
| Sep 3 | 1,519 |
| Sep 4 | 1,508 |
| Sep 5 | 1,472 |
| Sep 6 | 1,415 |
| Sep 7 | 1,345 |
| Sep 8 | 1,270 |
| Sep 9 | 1,202 |
| Sep 10 | 1,147 |
| Sep 11 | 1,114 |
| Sep 12 | 1,108 |
| Sep 13 | 1,131 |
| Sep 14 | 1,181 |
| Sep 15 | 1,254 |
| Sep 16 | 1,343 |
| Sep 17 | 1,441 |
| Sep 18 | 1,537 |
| Sep 19 | 1,623 |
| Sep 20 | 1,690 |
| Sep 21 | 1,731 |
| Sep 22 | 1,745 |
| Sep 23 | 1,731 |
| Sep 24 | 1,691 |
| Sep 25 | 1,631 |
| Sep 26 | 1,560 |
| Sep 27 | 1,486 |
Axis titles & compact figures#
ChartYAxis prints compact figures by default (12K, 1.4M), the way Mixpanel and Attio label an axis; pass tickFormatter for currency or units. Both axes take a label: the y title turns to run along the outer edge, the x title centers under the ticks, as in Attio’s report builder. Give the chart the room for them in padding.
| country | Companies |
|---|---|
| United States | 128 |
| United Kingdom | 64 |
| Germany | 41 |
| France | 33 |
| Spain | 27 |
| Netherlands | 19 |
| Sweden | 12 |
Negative values#
The domain anchors to zero, and bars and areas grow from the value baseline (the y-zero line), so positive values rise above it and negative values drop below. No extra config: pass data that crosses zero and it reads correctly.
| month | Net change |
|---|---|
| Jan | 12 |
| Feb | -8 |
| Mar | 15 |
| Apr | -4 |
| May | 22 |
| Jun | -11 |
| Jul | 18 |
| Aug | 9 |
Fitted domain#
A full chart starts its y-axis at zero, which is right for bars and totals. A balance or a rate moves in a band far from zero, and a zero floor flattens it into a line. Pass domain="fit" and the axis wraps the data’s own extent in nice rounded bounds, with ticks on a nice step, so the grid and the labels still land on round values. It never crosses zero when the data does not. A [min, max] pair still fixes the domain exactly.
auto (default): from zero
| week | Balance |
|---|---|
| Jul 5 | 1,674,200 |
| Jul 12 | 1,681,900 |
| Jul 19 | 1,690,400 |
| Jul 26 | 1,697,800 |
| Aug 2 | 1,709,600 |
| Aug 9 | 1,722,300 |
| Aug 16 | 1,738,900 |
| Aug 23 | 1,731,400 |
| Aug 30 | 1,768,200 |
| Sep 6 | 1,790,600 |
| Sep 13 | 1,805,300 |
| Sep 20 | 1,821,500 |
| Sep 27 | 1,842,300 |
fit: around the data
| week | Balance |
|---|---|
| Jul 5 | 1,674,200 |
| Jul 12 | 1,681,900 |
| Jul 19 | 1,690,400 |
| Jul 26 | 1,697,800 |
| Aug 2 | 1,709,600 |
| Aug 9 | 1,722,300 |
| Aug 16 | 1,738,900 |
| Aug 23 | 1,731,400 |
| Aug 30 | 1,768,200 |
| Sep 6 | 1,790,600 |
| Sep 13 | 1,805,300 |
| Sep 20 | 1,821,500 |
| Sep 27 | 1,842,300 |
Funnel#
ChartFunnel draws conversion through ordered steps, as Mixpanel and Attio do. Each step is a column, and above it a faint ghost rises to the step before, so what dropped off reads as the empty part of the column. Each step carries its conversion from the first, and ChartTooltip adds the conversion and drop-off rows by itself. Give the chart about 32px of padding.top for the first label.
| step | Users |
|---|---|
| Visited pricing | 12,480 |
| Started signup | 5,920 |
| Verified email | 4,310 |
| Created workspace | 3,180 |
| Invited a teammate | 1,240 |
Pie & donut#
ChartPie draws each row as a slice, clockwise from twelve o’clock, with a clean gap between slices. innerRadius sets the hole (0.62 by default, a donut; 0 for a pie), and its children center in the hole. Hovering a slice lifts it out a step while the rest recede, with its value and share in the tooltip. A ChartLegend in the same chart keys the slices in their hues and lights them from the key.
| source | Visits |
|---|---|
| Organic search | 18,420 |
| Direct | 9,310 |
| Referral | 5,870 |
| Social | 4,120 |
| 2,280 |
| stage | Deals |
|---|---|
| Lead | 42 |
| Qualified | 27 |
| Proposal | 16 |
| Negotiation | 9 |
| Won | 6 |
Horizontal bars#
ChartBarsHorizontal lays the categories down the side, so long names get a lane of their own instead of a rotated axis. It takes the plot over and draws its own category lane, value ticks and hairline grid. offset picks the shape: stack accumulates the keys, and expand normalizes each row to 100%, for the mix across categories of very different size; the tooltip keeps both the amount and the share. Pass label to print values inside the segments, only where they fit.
| region | Direct | Partners | Marketplace |
|---|---|---|---|
| North America | 1,840,000 | 920,000 | 610,000 |
| Europe | 980,000 | 1,120,000 | 340,000 |
| Asia Pacific | 520,000 | 460,000 | 890,000 |
| Latin America | 210,000 | 330,000 | 150,000 |
| Middle East & Africa | 160,000 | 120,000 | 90,000 |
offset="diverging" centers a Likert scale: the negative answers run left of the zero line, the positive ones right, and neutralKey straddles it, so each row’s lean reads at a glance. Color it from the chart-div-* ramp, with the hueless midpoint for Neutral.
| question | Strongly disagree | Disagree | Neutral | Agree | Strongly agree |
|---|---|---|---|---|---|
| The product is easy to set up | 4 | 9 | 17 | 46 | 24 |
| Support answers quickly | 8 | 14 | 22 | 38 | 18 |
| Pricing is fair for what I get | 15 | 24 | 26 | 27 | 8 |
| I would recommend it to a colleague | 3 | 7 | 15 | 41 | 34 |
The default offset="none" groups the keys side by side in each band. categoryWidth fixes the lane (by default it fits the longest name, up to 40% of the plot); a name that overflows truncates and shows in full on hover.
| feature | Before redesign | After redesign |
|---|---|---|
| Shared dashboards and scheduled reports | 1,240 | 1,860 |
| Role-based access control | 980 | 1,120 |
| Single sign-on (SAML / OIDC) | 610 | 940 |
| Audit log export to your data warehouse | 320 | 410 |
Scatter & bubble#
ChartScatter plots two numeric fields against each other on its own pair of axes. size turns the dots into bubbles (sized by area), and group names the field whose value is a config key, so each group takes its hue from the config order and a plain ChartLegend toggles it. The scales hold when a group is hidden, so the points that remain keep their place. One tooltip follows the nearest point, and the arrow keys step through the points in x order. Keep it to three groups: any two points can sit side by side, and only the first three hues stay apart pairwise.
| account |
|---|
| Acme |
| Globex |
| Initech |
| Umbrella |
| Hooli |
| Stark |
| Wayne |
| Wonka |
| Soylent |
| Tyrell |
| Cyberdyne |
| Aperture |
| Massive |
| Vandelay |
| Pied Piper |
| Gringotts |
| Oscorp |
| Monarch |
| Prestige |
| Dunder |
| Bluth |
| Nakatomi |
| Rekall |
| Virtucon |
| Krusty |
| Sirius |
| Wernham |
| Zorg |
| Vehement |
| Duff |
| Gekko |
| Ollivander |
| Kwik-E |
| Spacely |
| Cogswell |
| Primatech |
highlight answers one question: the points it returns true for keep their hue, the rest recede to a neutral.
| account | Deals |
|---|---|
| Acme | 405 |
| Globex | 440 |
| Initech | 215 |
| Umbrella | 378 |
| Hooli | 365 |
| Stark | 251 |
| Wayne | 354 |
| Wonka | 236 |
| Soylent | 364 |
| Tyrell | 518 |
| Cyberdyne | 100 |
| Aperture | 216 |
| Massive | 179 |
| Vandelay | 152 |
| Pied Piper | 196 |
| Gringotts | 64 |
| Oscorp | 140 |
| Monarch | 140 |
| Prestige | 163 |
| Dunder | 162 |
| Bluth | 135 |
| Nakatomi | 177 |
| Rekall | 27 |
| Virtucon | 60 |
| Krusty | 47 |
| Sirius | 31 |
| Wernham | 61 |
| Zorg | 65 |
| Vehement | 27 |
| Duff | 63 |
| Gekko | 16 |
| Ollivander | 42 |
| Kwik-E | 43 |
| Spacely | 68 |
| Cogswell | 44 |
| Primatech | 48 |
trend draws a least-squares line through each visible group, which says “paid scales, events plateau” faster than the cloud of points does.
| week |
|---|
| Paid W1 |
| Paid W2 |
| Paid W3 |
| Paid W4 |
| Paid W5 |
| Paid W6 |
| Paid W7 |
| Paid W8 |
| Paid W9 |
| Paid W10 |
| Paid W11 |
| Paid W12 |
| Paid W13 |
| Paid W14 |
| Paid W15 |
| Paid W16 |
| Paid W17 |
| Paid W18 |
| Paid W19 |
| Paid W20 |
| Events W1 |
| Events W2 |
| Events W3 |
| Events W4 |
| Events W5 |
| Events W6 |
| Events W7 |
| Events W8 |
| Events W9 |
| Events W10 |
| Events W11 |
| Events W12 |
| Events W13 |
| Events W14 |
| Events W15 |
| Events W16 |
| Events W17 |
| Events W18 |
| Events W19 |
| Events W20 |
Dumbbell & slope#
ChartDumbbell shows a before and an after per category on the chart’s own scale, so the grid, axes, tooltip and legend compose with it unchanged. The to end is the series hue, solid and a step larger; the from end is a lighter step of the same hue, and the legend draws it the same way, so direction reads without color. Pair the keys with compare to get the change in the tooltip.
Q1 vs Q2 conversion by channel
Checkout rate
| channel | Q2 | Q1 |
|---|---|---|
| Referral | 5.4 | 4.6 |
| 4.7 | 3.8 | |
| Search | 3.6 | 4.1 |
| Direct | 3.3 | 2.9 |
| Social | 1.8 | 2.2 |
| Display | 1.5 | 1.1 |
connector="direction" keeps rises in the series hue and mutes falls (never status colors: up is not automatically good), and label="both" labels each end.
Which channels improved
Q1 → Q2
| channel | Q2 | Q1 |
|---|---|---|
| Referral | 5.4 | 4.6 |
| 4.7 | 3.8 | |
| Search | 3.6 | 4.1 |
| Direct | 3.3 | 2.9 |
| Social | 1.8 | 2.2 |
| Display | 1.5 | 1.1 |
orientation="slope" transposes it: two rows (the periods, named by their index value in from and to) and one line per series, with end labels wherever they separate.
Conversion shift by channel
Q1 → Q2
| quarter | Referral | Search | Social | |
|---|---|---|---|---|
| Q1 | 4.6 | 3.8 | 4.1 | 2.2 |
| Q2 | 5.4 | 4.7 | 3.6 | 1.8 |
Category bar#
CategoryBar breaks one whole into its parts in a single line: credits by tool, storage by file type, time by project. It takes the same rows as a pie (each one a category, named by index, sized by dataKey), so where a donut spends a square, this sits under a figure or across a card. Each segment’s width is its share, with a clean gap between segments, and CategoryBarLegend keys them underneath with the share after each name. Hovering a segment or a key lights it and recedes the rest, with its amount and share in the tooltip. Give the long tail’s Other the gray hue.
size sets the thickness (6, 8 or 12px), palette="tonal" paints an ordinal one-hue ramp instead of distinct hues, and the legend’s value prints the share, the amount (through valueFormatter), both, or nothing.
size="sm"
size="md"
size="lg", palette="tonal", value="both"
Sparkline#
Pass sparkline for a chromeless trend: zero padding (it bleeds to the edge), points spanning the full width, and currentColor so a single text-* utility sets the hue. This is exactly what StatSparkline renders under the hood.
Revenue
Sessions
Refunds
Sparkline bars#
A sparkline can draw bars too, for a week of orders beside a figure. Once a ChartBar is in it, the categories sit in bands (the first and last bars keep their full width) and the scale runs from zero, so the shortest bar still reads as a bar. Add ChartTooltip for a hover readout, and highlight to light today.
Orders
344
Refunds
9
Colors#
Series without a color follow the chart’s palette: categorical (the default) walks the validated order chart-1 to chart-8: blue, green, pink, orange, sky, purple, amber, teal. Two series read blue and green, a third adds pink. To pin a hue, pass a slot as color, a status role, or current to inherit the ambient color; the named hues (blue, teal, purple…) stay for back-compat. The order goes by each key’s place in config, so a series keeps its hue when another is hidden or empty, and never cycles: past eight, fold the rest into “Other”; tonal spreads the sequential ramp (chart-seq-7 to chart-seq-3) for ordered tiers.
chart-1 · Blue
chart-2 · Green
chart-3 · Pink
chart-4 · Orange
chart-5 · Sky
chart-6 · Purple
chart-7 · Amber
chart-8 · Teal
Loading & empty#
Pass loading to render a Skeleton in place of the plot (it also sets aria-busy). When data is empty, the chart shows a muted message; override it with the empty prop.
With data
| month | Revenue |
|---|---|
| Jan | 4,200 |
| Feb | 3,800 |
| Mar | 5,100 |
| Apr | 4,600 |
| May | 6,200 |
| Jun | 5,400 |
| Jul | 7,100 |
| Aug | 6,500 |
Loading
Empty
No data to display
Accessibility#
The SVG is decorative (aria-hidden): pixels do not read well to a screen reader. Instead, every full chart renders a visually-hidden data table as its accessible equivalent, so assistive tech gets the real numbers, row by row. Pass label to name the chart, it becomes the table’s caption. loading sets aria-busy. Sparklines stay decorative (no table), since they are labelled by their surrounding context, like a Stat’s value.
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
API reference#
Chart
The root: measures itself, builds the scales and shares them with every part, which draw into one SVG. Renders a visually hidden data table for screen readers. Forwards all native <div> props, ref included. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| data* | ChartDatum[] | number[] | - | A row per category, or a bare number[] for a single value series. null marks a missing point. |
| index | string | - | The key holding each row's category label, for the x-axis and tooltip heading. |
| config | Record<string, ChartSeriesConfig> | - | Per series: label, color, format, axis (deprecated: draw two aligned charts instead), compare (the key it is measured against) and inverted (down is good). A ChartColor is a chart role (chart-1 to chart-8, chart-seq-1 to chart-seq-7, chart-div-1 to chart-div-7, chart-good / warning / serious / critical), a semantic hue kept for compatibility (blue, teal, brand, gray, blue-200 to blue-800…) or current. |
| domain | "auto" | "fit" | [number, number] | "auto" | auto runs from zero to a nice top; fit wraps the data's own extent; a pair fixes it. |
| sparkline | boolean | false | Chromeless: zero padding, points across the full width, painted in currentColor. |
| stack | boolean | false | Stacks ChartBars and ChartAreas, and sizes the domain to the category total. |
| palette | "categorical" | "tonal" | "categorical" | How series without a color are painted: the categorical order (stacks too), or tonal, an opt-in ordinal ramp for ordered tiers. |
| texture | boolean | false | Fills bars, areas and slices with a per-series 45°/135° line texture, so series stay apart without hue (color-vision deficiency, grayscale print, forced colors). |
| padding | Partial<{ top: number; right: number; bottom: number; left: number }> | - | The plot insets, in px. Raise bottom and left to make room for axes. |
| animate | boolean | true | The one-shot load reveal. Held under reduced motion. |
| crosshair | boolean | true (false for sparklines) | The hover tracking line, painted behind the data. |
| activeIndex | number | null | - | The hovered category, controlled. |
| onActiveIndexChange | (index: number | null) => void | - | Called as the pointer crosses categories, and with null when it leaves. |
| hiddenSeries | string[] | - | The series switched off, controlled. They leave the scale, stacks and tooltip. |
| defaultHiddenSeries | string[] | - | The series switched off at first, uncontrolled. |
| onHiddenSeriesChange | (keys: string[]) => void | - | Called when a series is shown or hidden. |
| focusedSeries | string | null | - | The series in focus, controlled; the rest recede. |
| onFocusedSeriesChange | (key: string | null) => void | - | Called when the focused series changes. |
| partial | boolean | number | - | Trailing categories still in progress (true is the last): lines dash, areas fade, bars hatch. |
| loading | boolean | false | A Skeleton in place of the plot, with aria-busy. |
| empty | React.ReactNode | "No data" | Shown when data is empty. |
| label | string | - | The accessible name; it also captions the hidden data table. Strongly recommended. |
ChartLine
A line series. Forwards SVG <path> props except d.
| Prop | Type | Default | Description |
|---|---|---|---|
| dataKey | string | "value" | The series to plot. |
| color | ChartColor | - | Overrides the hue from config. |
| curve | "linear" | "monotone" | "linear" | Straight segments, or a smooth curve that never overshoots. Match the area under it. |
| connectNulls | boolean | false | Bridges missing points instead of breaking the line. |
| dashed | boolean | false | A dashed line for projected data; skips the draw-in. |
| markEnd | boolean | false | A filled dot on the last point. |
| variant | "default" | "comparison" | - | comparison is the faint dashed ghost of a previous period, the default for a series another one compares against. |
| hideActiveDot | boolean | false | Hides the dot on the hovered point. |
| strokeWidth | number | - | The stroke width. |
ChartArea
An area series fading down from its edge; pair it with a ChartLine on top. Forwards SVG <path> props except d.
| Prop | Type | Default | Description |
|---|---|---|---|
| dataKey | string | "value" | The series to fill. |
| color | ChartColor | - | Overrides the hue from config. |
| curve | "linear" | "monotone" | "linear" | How the top edge joins its points. |
| connectNulls | boolean | false | Bridges missing points instead of leaving a hole. |
ChartAreas
Several area series at once, stacked into bands with stack on the root, each with its own edge line. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| keys | string[] | - | The series to draw, bottom of the stack first. Defaults to every series. |
| curve | "linear" | "monotone" | "linear" | How every band's edges join their points. |
| connectNulls | boolean | false | Bridges missing points instead of leaving a hole. |
ChartBar
A single bar series. Forwards SVG <path> props except d.
| Prop | Type | Default | Description |
|---|---|---|---|
| dataKey | string | "value" | The series to draw. |
| color | ChartColor | - | Overrides the hue from config. |
| barRatio | number | 0.62 | Bar width as a fraction of the category band. |
| radius | number | 8 | Corner radius at the value end, in px. |
| label | (value: number, index: number) => React.ReactNode | - | A value label past each bar's end. Give the Chart about 24px of padding.top. |
| highlight | number | number[] | "active" | ((datum, index, active) => boolean) | - | Bars painted in highlightColor: an index, a list, the hovered bar, or a predicate. |
| highlightColor | ChartColor | "primary" | The hue of a highlighted bar. |
ChartBars
Several bar series sharing each band: grouped, or stacked with stack on the root. Forwards SVG <path> props except d.
| Prop | Type | Default | Description |
|---|---|---|---|
| keys | string[] | - | The series to draw, in order. Defaults to every series. |
| barRatio | number | 0.7 | Group width as a fraction of the category band. |
| radius | number | 8 | Corner radius at each bar's value end; a stack rounds its outer segment only. |
ChartGrid
Horizontal grid lines on the y ticks. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| rows | number | 4 | The number of horizontal bands. |
| showVertical | boolean | false | Also draws a line per category. |
| baseline | boolean | true | Draws the zero line a step stronger, when zero is in the domain. |
ChartXAxis
The category labels under the plot. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| tickFormatter | (value: string | number, index: number) => string | - | Formats a category label. |
| interval | number | "auto" | 1 | Labels every Nth category, or auto: thins by measuring, counted back from the last category. |
| minTickGap | number | 12 | With auto: the minimum space between labels, in px. |
| minInterval | number | 1 | With auto: never label more often than every Nth category. |
| label | string | - | An axis title under the labels. Give the Chart about 24px more padding.bottom. |
ChartYAxis
The value ticks, in compact figures (12K, 1.4M) by default. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| count | number | 4 | The number of ticks. |
| tickFormatter | (value: number) => string | - | Formats a tick, e.g. as currency. |
| side | "left" | "right" | "left" | right labels the secondary scale on the right edge. |
| label | string | - | An axis title along the outer edge. Give the Chart about 20px more side padding. |
ChartReferenceLine
A threshold (y) or marker (x) across the plot; compose it after the data. Forwards SVG <line> props except x and y.
| Prop | Type | Default | Description |
|---|---|---|---|
| y | number | - | Draws a horizontal line at this value. |
| x | number | - | Draws a vertical line at this category index. |
| label | string | - | A label at the line's end. |
| variant | "dashed" | "solid" | "dashed" | The stroke. |
| color | ChartColor | - | The hue; a muted neutral by default. |
ChartTooltip
The hover bands and the shared bubble, a row per series. Takes only the props below.
| Prop | Type | Default | Description |
|---|---|---|---|
| valueFormatter | (value: number) => string | - | Formats each value. A series' own format wins. |
| labelFormatter | (value: string | number, datum: ChartDatum, index: number) => React.ReactNode | - | Formats the heading from the category, its row and index. |
| footer | (datum: ChartDatum, index: number) => React.ReactNode | - | Extra rows under a hairline; build them with ChartTooltipItem. |
| sort | "none" | "desc" | "asc" | "none" | Orders the rows by value at the hovered category. |
| total | boolean | string | - | Adds a total row ("Total", or your label). |
| maxItems | number | - | Folds the rows past this count into "+N more". |
| partialLabel | React.ReactNode | "In progress" | The heading of a partial category. |
| className | string | - | Merged onto the bubble. |
ChartTooltipItem
One tooltip row: swatch, label, right-aligned value. Works in footer and outside a Chart. Forwards native <span> props except children.
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | React.ReactNode | - | What the row measures. |
| value* | React.ReactNode | - | The figure. |
| color | ChartColor | - | The swatch hue; omit for no swatch. |
| change | number | null | - | A change printed before the value, as a fraction (0.12 is "+12%"). |
| inverted | boolean | false | Down is good: a fall prints green. |
| ghost | boolean | false | A comparison row with a faint swatch. |
| dimmed | boolean | false | Recedes the row. |
ChartLegend
The key. Inside a Chart it lists the series (or slices) above the plot and focuses, hides and isolates them; outside, a plain key. Forwards all native <div> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| config | ChartConfig | - | Outside a chart: entries from the same config the Chart takes. |
| items | { label: string; color?: ChartColor; value?: React.ReactNode; dataKey?: string }[] | - | Explicit entries; win over config and the chart's series. |
| align | "start" | "center" | "end" | "start" | The alignment of the row. |
| placement | "top" | "bottom" | "top" | Inside a chart: above or below the plot. |
| interactive | boolean | true | Hover focuses, click toggles, Alt+click isolates. false for a static key. |
| max | number | - | Folds the keys past this count into a "+N more" menu. |
| value | "last" | "sum" | "average" | ((key: string) => React.ReactNode) | - | A figure after each label, summarised from the data. |
| Data attribute | Description |
|---|---|
| data-hidden | On a key whose series is switched off (it also gets aria-pressed="false"). |
ChartAnnotation
A note pinned to a category: a marker in a lane above the plot that opens on hover. Forwards SVG <g> props except title.
| Prop | Type | Default | Description |
|---|---|---|---|
| index* | number | - | The category the note belongs to. |
| title* | React.ReactNode | - | The headline of the note. |
| label | React.ReactNode | - | What the marker shows (a number, a letter); omit for a dot. |
| description | React.ReactNode | - | More detail under the title. |
| color | ChartColor | - | The marker hue; the foreground by default. |
ChartFunnel
Ordered steps as columns, each with a ghost of the drop-off and its conversion from the first. Forwards SVG <path> props except d.
| Prop | Type | Default | Description |
|---|---|---|---|
| dataKey | string | "value" | The count at each step. |
| color | ChartColor | - | The column hue. |
| barRatio | number | 0.62 | Column width as a fraction of the band. |
| radius | number | 8 | Top corner radius, in px. |
| label | false | ((value: number, index: number, conversion: number) => React.ReactNode) | - | The label over each step; the conversion by default, false for none. |
ChartPie
A pie or donut, one slice per row named by the Chart's index. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| dataKey | string | "value" | The value each slice is sized by. |
| innerRadius | number | 0.62 | The hole as a fraction of the radius; 0 draws a pie. |
| gap | number | 2 | Space between slices, in px. |
| colors | ChartColor[] | - | Slice hues in row order; the palette by default. |
| valueFormatter | (value: number) => string | - | Formats the value in the slice tooltip. |
| tooltip | boolean | true | A tooltip per slice with its value and share. |
| children | React.ReactNode | - | Content centered in a donut's hole. |
ChartBarsHorizontal
Horizontal bars: categories down the side, values across. Takes the plot over and draws its own category lane, ticks and grid, with a tooltip per segment; Arrow keys walk the rows. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| keys | string[] | - | The keys to draw, in order; every series in config by default. |
| offset | "none" | "stack" | "expand" | "diverging" | "none" | Grouped, stacked, stacked to 100%, or a centered Likert scale. |
| neutralKey | string | - | Diverging: the key split across the zero line. |
| negativeKeys | string[] | - | Diverging: the keys drawn left of center; the first half of the non-neutral keys by default. |
| barSize | number | 20 | Bar thickness in px, never past 24. |
| categoryWidth | number | "auto" | "auto" | The category lane in px, or auto to fit the longest name (up to 40% of the plot). |
| valueFormatter | (value: number) => string | - | Formats ticks, labels and tooltips; a series' own format wins. |
| axis | boolean | true | Draws the value ticks and the hairline grid. |
| label | boolean | ((value: number, key: string, row: number) => React.ReactNode) | - | In-segment labels, drawn only where they fit. |
ChartScatter
A scatter or bubble plot with its own two numeric axes, one nearest-point tooltip and Arrow keys that step the points in x order. Its groups are the chart's series, so ChartLegend toggles them, and it renders its own screen-reader table. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| x* | string | - | The numeric field on the x-axis. |
| y* | string | - | The numeric field on the y-axis; without group, also the series key. |
| size | string | - | The numeric field that sizes each bubble (by area). Omit for plain dots. |
| group | string | - | The field whose value names a config key: the series a point belongs to. |
| xDomain | [number, number] | "auto" | "auto" | The x scale; auto fits the data with nice bounds. |
| yDomain | [number, number] | "auto" | "auto" | The y scale; auto fits the data with nice bounds. |
| sizeRange | [number, number] | [4, 20] | The bubble radius range, in px. |
| xLabel | string | - | The x-axis title, also used in the tooltip. |
| yLabel | string | - | The y-axis title, also used in the tooltip. |
| sizeLabel | string | - | What the tooltip calls the size field. |
| xFormatter | (value: number) => string | - | Formats x ticks and values. |
| yFormatter | (value: number) => string | - | Formats y ticks and values. |
| sizeFormatter | (value: number) => string | - | Formats the size value. |
| highlight | (row: ChartDatum) => boolean | - | Points it returns true for keep their hue; the rest recede to a neutral. |
| trend | boolean | false | A least-squares line through each visible group. |
ChartDumbbell
A before → after pair per category on the chart's value scale, composing with the grid, axes, tooltip and legend; with orientation="slope", a slope chart. Forwards SVG <g> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| from* | string | - | The "before" series key; for a slope, the index value of the "before" row. |
| to* | string | - | The "after" series key; for a slope, the index value of the "after" row. |
| connector | "neutral" | "direction" | "neutral" | A recessive connector, or rises in the series hue and falls muted. |
| label | "to" | "both" | "none" | "to" | Direct value labels on the endpoints. |
| valueFormatter | (value: number) => string | - | Formats the labels; a series' own format by default. |
| dotSize | number | 5 | The to dot's radius; the from dot sits one step smaller, never under 4. |
| orientation | "dumbbell" | "slope" | "dumbbell" | One row per category, or two rows (the periods) with one line per series. |
CategoryBar
One whole split into segments in a single bar, standalone (no Chart). Forwards native <div> props except children.
| Prop | Type | Default | Description |
|---|---|---|---|
| data* | ChartDatum[] | - | One row per category. |
| index | string | "label" | The key holding each category's name. |
| dataKey | string | "value" | The key holding each amount; shares come from the total. |
| colors | ChartColor[] | - | Segment hues in row order. Give "Other" gray. |
| palette | "categorical" | "tonal" | "categorical" | The hues for categories colors leaves out. |
| size | "sm" | "md" | "lg" | "md" | The track height: 6, 8 or 12px. |
| valueFormatter | (value: number) => string | - | Formats an amount in the tooltip and legend. |
| tooltip | boolean | true | A tooltip per segment: name, amount and share. |
| animate | boolean | true | Sweeps the bar open on mount. Held under reduced motion. |
| label | string | - | What the bar breaks down; leads its accessible name. |
| children | React.ReactNode | - | Parts under the bar: a CategoryBarLegend. |
CategoryBarLegend
The key under a CategoryBar; hovering a key recedes the other segments. Forwards all native <ul> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | "share" | "value" | "both" | "none" | "share" | What follows each name. |