Bar chart
Bars colored in with a marker that misses the outline a little, numbers on top, and the best day circled by hand. Hover or press the arrow keys: a highlighter lights the column and a slip of paper names it.
Charts drawn by hand: bars colored in with a marker, felt lines, pencil-shaded areas, pies, radars, dials, sparklines, tally marks and calendar heat maps. Real text on a real DOM, a keyboard cursor, a tooltip on a slip of paper, a legend that switches series off, a table for screen readers, and a pencil pattern on every series so color is never the only channel.
npx shadcn@latest add @wobko/chart第一次使用?先把 registry 加进 components.json。 如何安装
Bars colored in with a marker that misses the outline a little, numbers on top, and the best day circled by hand. Hover or press the arrow keys: a highlighter lights the column and a slip of paper names it.
One dataset, four ways to lay it out. Each series keeps its color and its pencil pattern (hatching, dots, cross-hatching), so the bars stay apart in grayscale. Negative values hang below the line.
A felt line per series, with a marker shape and a dash pattern for each so lines survive black-and-white print. The legend switches series off; the tooltip follows the pointer and the arrow keys.
The space under the line is washed with the series color and shaded in pencil: hatching, dots, cross-hatching. Stacked areas add up; the tooltip lists every layer.
Slices colored in with a marker, separated by felt lines, each with its own pencil pattern. The donut's hole is DOM text: it shows the total, and the slice under the pointer or the arrow keys.
A pencil web with a washed and shaded shape per series. The spokes are the keyboard stops: arrow keys walk from axis to axis and the tooltip reads every series on that spoke.
Concentric arcs in pale tracks, one ring per row, and a dial with marker zones and a red felt needle. The gauge is a role=meter: assistive tech reads its value, minimum and maximum.
One felt pull and a red dot at the end, a shaded area, or a row of marker bars. A sparkline is a picture with a spoken summary; set interactive to make it a chart you can hover.
A half year of days, each square colored in a shade of one marker; or any grid of your own. Arrow keys walk it in two dimensions: left and right by week, up and down by day.
Counts as hand-tallied marks: four uprights and a slash across for every five, in the color of the row. When a row is too long for the width, each mark starts to stand for more and says so.
Points on two number lines, each series with its own marker shape (circle, square, triangle). Give a size key and the points grow into bubbles. Long point clouds are thinned so the drawing stays light.
A note is a hand-drawn loop, an arrow and a line of script; a highlight marks a stretch of days with a highlighter, written after the chart appears. Point it at max, min, first, last, a category or an index; underline instead of circling; add a dashed goal line. Text is real DOM text and the note is part of the chart's spoken summary.
Every legend entry is a button with aria-pressed: switch a series off (struck through) and on again. A series keeps its color, marker and dash while it is away. Control it from outside with hiddenSeries.
A page of cards: stat tiles with sparklines, an area chart, a bar chart and a donut, drawn by hand. Press "calm" for the dense-screen version: hairline rules, no fill offset, no jitter, a busy page that stays quiet.
New points arrive every second and the chart is drawn again, not reflowed: the hand stays the same, so the line seems to move by itself. The wipe-on animation plays once; a redraw is silent. Pause to read the tooltip.
A chart with nothing to draw sketches its axes and a wandering pencil line and says so; a loading chart pulses dashed ghost bars and is aria-busy. Neither is interactive, and both keep their name and a spoken summary.
ChartTooltipContent keeps shadcn's props: indicator (dot, line, dashed), hideLabel, hideIndicator, labelFormatter and formatter. Or pass any element as content: it is cloned with active, payload and label. defaultIndex opens a tooltip on load.
Every series carries a pencil pattern (hatching, dots, cross-hatching, rules, scribble) on its marks, and a marker shape and a dash pattern on its lines. Switch to grayscale to see the chart still reads; switch the patterns off (`patterns={false}`) to see what plain color would have left you.
One series washed in marker and shaded in pencil, a felt line along the top. Hover or use the arrow keys: the tooltip's `indicator="line"` gives it a bar instead of a chip, and a hand-drawn note points at the peak. The axis says Jan; `labelFormatter` reads the whole month from the row for the slip.
`curve="linear"` joins the points with straight pencil strokes instead of the default smooth curve. The tooltip drops its label with `hideLabel`.
`curve="step"` holds each value until the next category, like a ledger. A config `icon` replaces the swatch in the tooltip and the legend.
Each month scaled to its own total, so the layers show shares. The rows are turned into percentages first (`visitorsShare` in `_data.ts`), then stacked with `yDomain={[0, 100]}`; the axis gets its % from `yFormatter`.
`stacked` piles the series on top of each other; `series` sets the order from the bottom up. Each keeps its own wash and pencil pattern, so the layers stay apart in grayscale.
`<ChartLegend />` lists the series with the very swatches the drawing uses. Every entry is a button: switch a series off and it is struck through and leaves the chart.
Without `stacked` the series are drawn over each other from zero, each with its own wash, so a smaller series shows through the bigger one. The tooltip lists both.
Both axes drawn: the category names along the bottom, a few tidy ticks up the side, and broken pencil rules across. `showXAxis` and `showYAxis` switch either off.
A config `icon` stands in for the swatch in the legend and the tooltip. Here they are the two hand-drawn trend arrows.
A Select in the card header picks how much of the ninety-one days to draw. The chart redraws with its new data and stays quiet: the wipe-on plays once. Dates are cut from the row's own text, so nothing depends on a locale or a time zone.
Bars colored in with a marker that misses the outline a little, the number on top of each, and the best month circled by hand. `tape` holds the card to the desk.
`horizontal` turns the bars sideways: categories down the left, the value along the bottom. The arrow keys walk the rows with up and down.
A color and a pencil pattern for every bar. One column per browser (`browserColumns` in `_data.ts`), stacked, gives each category its own series, so the tooltip and the table name it too.
Several series side by side in each category. Color is never the only channel: the second series is shaded with a different pencil pattern. The tooltip's `indicator="dashed"` marks its rows with a dashed rule.
`stacked` piles the bars up; the legend under the chart switches a series off and the rest close ranks.
One bar picked out: a highlighter swipe behind Firefox (`highlights`), and `defaultIndex` opens its tooltip before anyone touches the chart.
`showValues` writes the number on top of every bar, in the script hand. With `auto` (the default) they appear only when they fit.
Values below zero hang from the baseline. To color the gains and the losses apart the rows are split into two columns (`swingColumns` in `_data.ts`) and stacked, so each sign gets its own color and pencil pattern.
Two big buttons total the columns and choose which one the chart draws. They are ordinary toggle buttons with `aria-pressed`; the chart takes the chosen key as its only series.
One felt-tip pull through the points, smoothed so it never overshoots a peak. `dots={false}` leaves the markers out; the hand-written note circles the dip. A paper clip holds the card.
`curve="linear"` draws straight segments between the points, like a ruler and a felt tip.
`curve="step"` holds each value until the next category, then jumps.
Two lines, told apart by more than color: each series gets its own dash pattern (solid, dashed, dotted). Try the grayscale example if you doubt it.
The marker shape is a config choice per series: circle, square, triangle, diamond, cross or plus. Here desktop is drawn with diamonds and mobile with squares, and the legend shows the same little line sample.
`dots` puts a hand-drawn marker on every point. With `dots="auto"` (the default) they appear when there are few points and room for them.
The same two-button header as the bar version; the chart draws the chosen key as a single line. Dates on the axis are cut from the row's text, with no locale or time zone involved.
Slices colored in with a marker, outlined in felt, each shaded with its own pencil pattern. Arrow keys walk the slices. `showLabels={false}` leaves the percentages off.
The default: every slice is labeled with its share, written round the outside in the script hand.
`<ChartLegend />` names the slices with the swatches the drawing uses, and each entry switches its slice off; the pie redraws from the rest.
`defaultIndex` lights the first slice before anyone hovers, and the hole tells its story. Move over another slice, or use the arrow keys, and the light and the text follow.
The hole is real DOM text: a number in the script hand and a caption. Here it is the total; a function of `{ total, active }` can show the slice under the pointer instead.
`DonutChart` is a pie with a hole (`innerRadius` 0.58 of the radius).
A Select in the header chooses the month whose slice is lit (`defaultIndex`); the number in the hole follows. `defaultIndex` is read when the chart mounts, so the chart is keyed on the month and draws itself again. Hovering any slice still takes over.
A pencil web with one shaded shape. The spokes are the keyboard stops: left and right walk the axes. A staple holds the card.
`dots` marks every vertex with a hand-drawn marker (the default is on).
`fill={false}` draws the outlines and nothing else, which keeps two close series readable.
Two shapes on one web, each washed in its color and shaded with its own pencil pattern.
A config `icon` stands in for the swatch in the legend and the tooltip.
The legend switches a shape off and the web redraws with the other one.
The rings carry their values (`levels` sets how many, `max` where the rim is), written in the gap between the first two spokes in the script hand, so the web reads like a radius axis.
`startAngle` and `endAngle` set the sweep: here a full circle, so every ring sits in its pale track like a polar grid.
One ring per row, filled to its value against `max`. On the default three-quarter dial the ring names sit in the open quadrant, in the script hand.
One ring on a three-quarter dial with its number in the middle: 1,260 visitors against a goal of 1,500. The hole is DOM text, so it can hold anything.
A full circle filled to 80%: 200 of 250. Text in the hole, and the tooltip says how much of the goal is done.
The default `ChartTooltipContent`: a label in the script hand, then a row per series with a swatch identical to the drawing. `defaultIndex` opens it on the second bar before anything is hovered.
`indicator="dashed"` marks each row with a dashed pencil rule instead of a swatch.
`indicator="line"` gives each row a narrow bar in the series color and pencil pattern.
`hideIndicator` leaves the swatches out; the rows keep the series names.
`labelKey` looks the label up in the chart config instead of using the category: here the config's `activities` entry titles the slip.
`labelFormatter` turns the label into something to read: 2024-07-16 becomes July 16, 2024. It receives the label and the tooltip rows, and each row carries its data, so the whole date can be read from there.
`hideLabel` drops the category name, and `hideIndicator` the swatches: a bare list of values.
`formatter` replaces a whole row. It gets the value, the series name, the item and the row of data, and returns any markup, here a unit after the number.
A config `icon` takes the place of the swatch in the tooltip (and in a legend, if there is one).
A custom formatter that draws the swatch itself with `ChartSwatch` (the same chip the drawing uses) and adds a total row under the last series.
`keys` lists only these entries, in this order: the chart draws three series, the key names two of them, mobile first.
`toggle={false}` makes the legend a plain key: swatches and words, no buttons. Use it where the chart should not change.
Put `<ChartLegend verticalAlign="top" />` before the chart and it sits above it, with its padding on the side that faces the drawing.
The frame around a chart and its legend and tooltip. Same job as shadcn's: it owns the config and puts the series colors on the frame as `--color-<key>` (a `theme` gives a light and a dark value). It also owns which series are switched off. The drawing is not recharts: every chart component in this file draws itself with the ink engine.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| config | ChartConfig | - | `{ desktop: { label: 'Desktop', color: 'var(--chart-1)' } }`. A key's position is its palette slot (`--chart-1` is the marker orange, then blue felt, green pencil, deep highlighter, grape). Add `pattern`, `marker` and `dash` to override the look a series gets. |
| patterns | boolean | "auto" | solid, patterns in forced colors | Solid color by default. `"auto"` adds pencil patterns on filled marks and dashes on lines when there is more than one series, `true` always does. With no value, patterns switch on by themselves when the system forces its own colors. |
| hiddenSeries | string[] | - | Series (or slices) switched off, controlled. The legend buttons toggle them. |
| defaultHiddenSeries | string[] | - | Uncontrolled start value. |
| onHiddenSeriesChange | (hidden: string[]) => void | - | A legend button was pressed. |
| initialDimension | { width: number; height: number } | - | Draw at this size on the server and before the first measure, so the chart is part of the server HTML. |
| className | string | - | Sizes the frame: `aspect-auto h-64 w-full`. It is `aspect-video` by default, like shadcn's. A chart takes its size from the frame, so give it a height or a ratio: `aspect-auto` with no height is 0 px tall. |
The `<style>` that carries `--color-<key>` for each config entry (light and `.dark`). ChartContainer renders it for you.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| id | string | - | The container's `data-chart` value. |
| config | ChartConfig | - | The config to write out. |
Switches the tooltip on. It renders nothing itself: the chart draws the tooltip inside its own box, where the point is, and keeps it in view. Hover, touch and the arrow keys all move it.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| content | ReactElement | <ChartTooltipContent /> | Cloned with `active`, `payload` and `label`. Any component that takes those works. |
| defaultIndex | number | - | Show this data point when nothing is hovered or focused. |
| cursor | boolean | true | Kept for shadcn parity. The highlighter behind a column and the ring on a point are part of the drawing. |
The slip of paper: a label in the script font and one row per series with a swatch that matches the drawing (color, pattern, marker). Same props as shadcn's; the payload is recharts-shaped so an existing `formatter` keeps working.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| indicator | "dot" | "line" | "dashed" | "dot" | The swatch: a chip (a line swatch for line series), a narrow bar, or a dashed rule. |
| hideLabel | boolean | false | Leave out the label. |
| hideIndicator | boolean | false | Leave out the swatches. |
| labelFormatter | (label: ReactNode, payload: ChartTooltipItem[]) => ReactNode | - | Change the label. |
| formatter | (value, name, item, index, payload) => ReactNode | - | Replace a whole row. |
| nameKey / labelKey | string | - | Which payload key names a row / the label in the config. |
| color | string | - | Force the indicator color. |
| className / labelClassName | string | - | Merged onto the slip / the label. |
The key of the chart in this container. Place it before (`verticalAlign="top"`) or after the chart. It shows the series the chart registered, with the very swatches the drawing uses.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| content | ReactElement | <ChartLegendContent /> | Custom legend markup. |
| verticalAlign | "top" | "bottom" | "bottom" | Which side gets the padding. |
| keys | string[] | - | Only these entries, in this order. |
| toggle | boolean | true | Entries are buttons (aria-pressed) that switch a series off and on. `false` makes a plain key. |
The default legend body; same props as ChartLegend without `content`. `hideIcon` drops the config icon or swatch.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| hideIcon | boolean | false | Leave out the swatch / icon. |
The little chip of a legend or tooltip row: the series' marker fill, its pencil pattern, in a tiny felt box (`line` draws a line sample with its marker and dash).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| palette | number | - | The series' slot (its position in the config). |
| pattern | "solid" | "hatch" | "dots" | "cross" | "lines" | "scribble" | "solid" | The pencil pattern. |
| marker | MarkerShape | - | Line swatches: the marker on the sample. |
| line | boolean | - | A line sample instead of a filled chip. |
The words in the hole of a donut or radial chart: a big number in the script font and a small caption. `centerLabel` takes one, a node, or a function of the total and the slice under the cursor.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value | ReactNode | - | The big text. |
| label | ReactNode | - | The caption. |
Bars: single, grouped, stacked or sideways, with negative values hanging below the line. Bars are filled edge to edge in solid color, with a steady felt outline rounded at the far end. The highest bar can be circled by hand.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| horizontal | boolean | false | Bars run sideways, categories down the left (ignored when a series is not a bar). |
| layout | "horizontal" | "vertical" | - | recharts' name for the same thing: "vertical" runs the bars sideways. |
| data | Record<string, unknown>[] | - | One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so. |
| xKey | string | - | The category key (a scatter's x number). Default: the first key whose value is text. |
| series | string[] | - | Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data. |
| kinds | Record<string, "bar" | "line" | "area" | "scatter"> | - | Mix marks: `{ revenue: "bar", target: "line" }`. |
| stacked | boolean | false | Stack bars (or areas). Positive values stack up from zero, negative ones down. |
| curve | "smooth" | "linear" | "step" | "smooth" | How lines and areas join their points. Smooth is monotone: it never overshoots a peak. |
| yDomain | [number | "auto", number | "auto"] | - | Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false. |
| zero | boolean | - | Whether the value axis includes zero. Default: yes for bars and areas, no for lines. |
| xFormatter | (value: unknown, index: number) => string | - | Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value. |
| yFormatter | (value: number) => string | - | Text of an axis tick. Default: compact numbers (1.2k, 3.4M). |
| valueFormatter | (value: number) => string | - | Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234. |
| dots | boolean | "auto" | "auto" | Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape. |
| showValues | boolean | "auto" | "auto" | Numbers on top of bars: drawn when they fit (wide enough, not stacked). |
| showGrid | boolean | true | Broken pencil rules across the plot. |
| showXAxis / showYAxis | boolean | true | Axis labels (the baseline is always drawn). |
| annotations | ChartAnnotation[] | - | Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none. |
| references | ChartReference[] | - | Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`). |
| highlights | ChartHighlight[] | - | A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary. |
| label | string | - | The chart's accessible name and the start of its summary. |
| description | string | - | One more sentence for the spoken summary. |
| xLabel | string | - | Name of the category column in the data table. |
| loading | boolean | - | Ghost bars pulse, the chart is aria-busy and not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it. |
| seed | string | number | - | Pins the hand. |
| accessibilityLayer | boolean | - | Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point (drill down, filter). |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
A felt line per series, with a marker shape and a dash pattern each so lines survive grayscale. Gaps in the data break the line. Long series keep their peaks and dips.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so. |
| xKey | string | - | The category key (a scatter's x number). Default: the first key whose value is text. |
| series | string[] | - | Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data. |
| kinds | Record<string, "bar" | "line" | "area" | "scatter"> | - | Mix marks: `{ revenue: "bar", target: "line" }`. |
| stacked | boolean | false | Stack bars (or areas). Positive values stack up from zero, negative ones down. |
| curve | "smooth" | "linear" | "step" | "smooth" | How lines and areas join their points. Smooth is monotone: it never overshoots a peak. |
| yDomain | [number | "auto", number | "auto"] | - | Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false. |
| zero | boolean | - | Whether the value axis includes zero. Default: yes for bars and areas, no for lines. |
| xFormatter | (value: unknown, index: number) => string | - | Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value. |
| yFormatter | (value: number) => string | - | Text of an axis tick. Default: compact numbers (1.2k, 3.4M). |
| valueFormatter | (value: number) => string | - | Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234. |
| dots | boolean | "auto" | "auto" | Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape. |
| showValues | boolean | "auto" | "auto" | Numbers on top of bars: drawn when they fit (wide enough, not stacked). |
| showGrid | boolean | true | Broken pencil rules across the plot. |
| showXAxis / showYAxis | boolean | true | Axis labels (the baseline is always drawn). |
| annotations | ChartAnnotation[] | - | Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none. |
| references | ChartReference[] | - | Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`). |
| highlights | ChartHighlight[] | - | A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary. |
| label | string | - | The chart's accessible name and the start of its summary. |
| description | string | - | One more sentence for the spoken summary. |
| xLabel | string | - | Name of the category column in the data table. |
| loading | boolean | - | Ghost bars pulse, the chart is aria-busy and not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it. |
| seed | string | number | - | Pins the hand. |
| accessibilityLayer | boolean | - | Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point (drill down, filter). |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Lines with the space under them washed in the series color and shaded in pencil. Stack them with `stacked`.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so. |
| xKey | string | - | The category key (a scatter's x number). Default: the first key whose value is text. |
| series | string[] | - | Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data. |
| kinds | Record<string, "bar" | "line" | "area" | "scatter"> | - | Mix marks: `{ revenue: "bar", target: "line" }`. |
| stacked | boolean | false | Stack bars (or areas). Positive values stack up from zero, negative ones down. |
| curve | "smooth" | "linear" | "step" | "smooth" | How lines and areas join their points. Smooth is monotone: it never overshoots a peak. |
| yDomain | [number | "auto", number | "auto"] | - | Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false. |
| zero | boolean | - | Whether the value axis includes zero. Default: yes for bars and areas, no for lines. |
| xFormatter | (value: unknown, index: number) => string | - | Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value. |
| yFormatter | (value: number) => string | - | Text of an axis tick. Default: compact numbers (1.2k, 3.4M). |
| valueFormatter | (value: number) => string | - | Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234. |
| dots | boolean | "auto" | "auto" | Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape. |
| showValues | boolean | "auto" | "auto" | Numbers on top of bars: drawn when they fit (wide enough, not stacked). |
| showGrid | boolean | true | Broken pencil rules across the plot. |
| showXAxis / showYAxis | boolean | true | Axis labels (the baseline is always drawn). |
| annotations | ChartAnnotation[] | - | Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none. |
| references | ChartReference[] | - | Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`). |
| highlights | ChartHighlight[] | - | A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary. |
| label | string | - | The chart's accessible name and the start of its summary. |
| description | string | - | One more sentence for the spoken summary. |
| xLabel | string | - | Name of the category column in the data table. |
| loading | boolean | - | Ghost bars pulse, the chart is aria-busy and not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it. |
| seed | string | number | - | Pins the hand. |
| accessibilityLayer | boolean | - | Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point (drill down, filter). |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Points on two number lines, one marker shape per series; a `sizeKey` turns them into bubbles. Up to 600 points are drawn; the tooltip finds the nearest point.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| sizeKey | string | - | The data key that sizes each point. |
| data | Record<string, unknown>[] | - | One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so. |
| xKey | string | - | The category key (a scatter's x number). Default: the first key whose value is text. |
| series | string[] | - | Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data. |
| kinds | Record<string, "bar" | "line" | "area" | "scatter"> | - | Mix marks: `{ revenue: "bar", target: "line" }`. |
| stacked | boolean | false | Stack bars (or areas). Positive values stack up from zero, negative ones down. |
| curve | "smooth" | "linear" | "step" | "smooth" | How lines and areas join their points. Smooth is monotone: it never overshoots a peak. |
| yDomain | [number | "auto", number | "auto"] | - | Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false. |
| zero | boolean | - | Whether the value axis includes zero. Default: yes for bars and areas, no for lines. |
| xFormatter | (value: unknown, index: number) => string | - | Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value. |
| yFormatter | (value: number) => string | - | Text of an axis tick. Default: compact numbers (1.2k, 3.4M). |
| valueFormatter | (value: number) => string | - | Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234. |
| dots | boolean | "auto" | "auto" | Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape. |
| showValues | boolean | "auto" | "auto" | Numbers on top of bars: drawn when they fit (wide enough, not stacked). |
| showGrid | boolean | true | Broken pencil rules across the plot. |
| showXAxis / showYAxis | boolean | true | Axis labels (the baseline is always drawn). |
| annotations | ChartAnnotation[] | - | Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none. |
| references | ChartReference[] | - | Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`). |
| highlights | ChartHighlight[] | - | A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary. |
| label | string | - | The chart's accessible name and the start of its summary. |
| description | string | - | One more sentence for the spoken summary. |
| xLabel | string | - | Name of the category column in the data table. |
| loading | boolean | - | Ghost bars pulse, the chart is aria-busy and not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it. |
| seed | string | number | - | Pins the hand. |
| accessibilityLayer | boolean | - | Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point (drill down, filter). |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Slices colored in with a marker, outlined in felt, each with its own pencil pattern and a percentage round the outside. Arrow keys walk the slices; the legend switches them off.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per slice. |
| nameKey | string | - | The key that names a slice and finds its config entry. Default: the first key with text. |
| valueKey | string | - | The key with the amount. Default: the first numeric key. |
| innerRadius | number | 0 | Fraction of the radius that is hole (0 to 0.9). |
| startAngle | number | 0 | Degrees clockwise from twelve o'clock. |
| showLabels | boolean | true | Percentages round the outside. |
| centerLabel | ReactNode | { value, label } | (info: { total, active }) => ReactNode | - | Text in the hole. |
| valueFormatter | (value: number) => string | - | Number text. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
A PieChart with a hole (`innerRadius` 0.58) for a number in the middle.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| innerRadius | number | 0.58 | Fraction of the radius that is hole. |
| centerLabel | ReactNode | { value, label } | function | - | Text in the hole. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
A pencil web with a washed and shaded shape per series. The spokes are the keyboard stops.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per axis. |
| xKey | string | - | The key that names an axis. |
| series | string[] | - | Keys to draw. |
| max | number | - | The value at the rim. Default: a tidy number above the largest value. |
| levels | number | 4 | Rings of the web. |
| fill | boolean | true | Shade the shapes. |
| dots | boolean | true | A marker on each vertex. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Concentric arcs in pale tracks: one ring per row, filled to its value. Ring names sit in the open quadrant.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per ring; a row's own `max` overrides `max`. |
| nameKey / valueKey | string | - | Which keys name and size a ring. |
| max | number | 100 | The value that fills a ring. |
| startAngle / endAngle | number | 0 / 270 | Degrees clockwise from twelve o'clock. |
| centerLabel | ReactNode | { value, label } | - | Text in the hole. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
A dial: marker zones (each with a pencil pattern) and a red felt needle, or a single colored arc. `role="meter"` with a value, a minimum, a maximum and a text, so assistive tech reads it. The children are the text under the pivot.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value | number | - | The reading; clamped to min and max. |
| min / max | number | 0 / 100 | The ends of the dial. |
| zones | { to: number; tone?: 'good' | 'warn' | 'bad' | 'info' | 'brand' | number }[] | - | Colored stretches from the minimum up. |
| sweep | number | 180 | Degrees the dial covers (180 is a half circle). |
| ticks | number | 10 | Pencil ticks round the outside. |
| valueFormatter | (value: number) => string | - | Number text. |
| label | string | - | The accessible name. |
| children | ReactNode | - | Text under the pivot. Default: the value. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
One felt pull and a red dot at the end, a shaded area, or a row of marker bars, at 112 x 40 px unless you size it. A picture with a spoken summary; `interactive` makes it a chart with a cursor and a tooltip.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | (number | null)[] | Record<string, unknown>[] | - | Numbers, or rows with `dataKey`. |
| dataKey / xKey | string | - | For rows: the value and the category key. |
| variant | "line" | "area" | "bar" | "line" | How it is drawn. |
| slot / series | number / string | - | Palette slot, or the config key whose color to use. |
| ends | boolean | true | A red dot on the last point. |
| extremes | boolean | false | Small marks on the lowest and highest points. |
| interactive | boolean | false | Hover and arrow keys show a tooltip. |
| label | string | - | The accessible name. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Counts as hand-tallied marks: four uprights and a slash across for every five, in the color of the row. When a row is too long for the width each mark stands for more, and the chart says so.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | One row per line of the board. |
| nameKey / valueKey | string | - | Which keys name and count a row. |
| unit | number | auto | What one mark stands for. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
Squares colored in shades of one marker: a calendar (weeks across, weekdays down, month names on top) or a grid of your own rows and columns. Arrow keys move over the cells: left and right by week, up and down by day.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | Record<string, unknown>[] | - | Calendar: rows with a date and a value. Grid: rows with a row name, a column name and a value. |
| variant | "calendar" | "grid" | "calendar" | The layout. |
| dateKey / valueKey | string | "date" / "value" | Calendar keys. Dates are `YYYY-MM-DD` or Date, read in UTC. |
| weeks / end / weekStart | number / string | Date / 0 | 1 | - | Weeks shown, the last day, and whether weeks start on Sunday (0) or Monday (1). |
| rowKey / colKey / rows / cols | string / string[] | - | Grid keys and the order of rows and columns. |
| levels / thresholds | number / number[] | 5 | Shades, and optionally the value at which each starts. |
| slot / series | number / string | - | Palette slot, or the config key whose color to use. Default the green pencil. |
| unit | string | - | What a value counts ("pages"), shown in the tooltip. |
| showLegend | boolean | true | The Less / More key. |
| label | string | - | The accessible name and the start of the spoken summary. |
| description | string | - | One more sentence for the summary. |
| loading | boolean | - | Ghost drawing, aria-busy, not interactive. |
| emptyText | string | - | Text shown when there is nothing to draw. |
| animate | boolean | true | Wipe on once when it first appears. |
| seed | string | number | - | Pins the hand. |
| onActiveChange | (info: { index: number; series: number | null } | null) => void | - | The data point under the pointer or the keys changed. |
| onSelect | (info: { index: number; series: number | null }) => void | - | A click, Enter or Space on a data point. |
| config / tooltip / legend / className | ChartConfig / boolean / boolean | 'top' | 'bottom' / string | - | Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing. |
CLI 会复制进你项目的文件。
正在加载源码