Pro (paid add-on)
Charts
ProBar, line, area, pie, scatter, heatmap, gauge and sparkline charts everyone can read: keyboard and screen reader access to every point, a data table, colors checked for color blindness, and High Contrast support.
Part of Pro
This page documents part of @vjdesigns-pro/ui, the paid add-on package. Using it needs a Pro license and @vjdesigns/vjdesigns-ui 3.8.0 or later. Like the free package, it works in both modes, every brand, all 32 languages and right to left. Install it as described in Account forms.
Example
Every chart takes plain rows of data and a title. LineChart and AreaChart take the same props as BarChart, for change over time. A null value leaves a gap instead of drawing a false line.
import { BarChart } from "@vjdesigns-pro/ui";
<BarChart
title="Box score by game"
description="Rebounding held steady while scoring climbed."
data={games}
x="opponent"
xLabel="Opponent"
series={[
{ key: "points", label: "Points" },
{ key: "rebounds", label: "Rebounds" },
]}
/>;
Chart types
BarChart: comparing values across categories. Grouped side by side, orstacked(the tooltip, labels and table add a total).LineChart: change over time. Up to four series are labeled at their ends.AreaChart: one series over time, orstackedparts of a total.PieChartandDonutChart: one whole split into a few parts, read at a glance. PastmaxSlices(6) the smallest parts fold into "Other". For close values or ranking, use aBarChart.ScatterChart: how two measures relate. Up to three colored groups; hover snaps to the nearest dot.Heatmap: patterns across two categories, on one blue ramp with a scale.showValuesprints the numbers in ink checked for contrast.Gauge: one value in a known range. Arole="meter"with the number in the middle and an optionaltarget.Sparkline: a word-sized trend in a stat tile or table row, named by a summary ("Points: from 58 to 72, low 55, high 80").
More chart types
<PieChart title="Points by shot type" data={shots} label="type" value="points"
labelHeader="Shot type" valueHeader="Points" />
<ScatterChart title="Minutes and points" data={players} x="minutes" y="points"
xLabel="Minutes" yLabel="Points" name="player" nameLabel="Player"
group="position" groupLabel="Position" />
<Heatmap title="Points by quarter" data={cells} x="quarter" y="player" value="points"
yLabel="Player" valueLabel="Points" />
<Gauge label="Free throw percentage" value={76} target={80} formatValue={(v) => `${v}%`} />
<Sparkline label="Points" data={[58, 64, 61, 72]} />
Patterns for color-blind viewers
About 1 in 12 men and 1 in 200 women have some form of color blindness, so every series can be drawn with a pattern as well as a color: hatched, dotted and crosshatched fills for bars, areas and slices, dashed and dotted lines, and circles, squares, triangles and other shapes for scatter points. Legends show the same patterns. Every chart with two or more series has a Patterns toggle button next to "Show data table" (aria-pressed), so viewers can switch them on themselves.
defaultPatternsturns them on from the start, or control them withpatternsandonPatternsChange.- Choose a series' pattern with
dash(lines) orfill(bars and areas). Series without a choice take the next pattern no other series uses, so two series never look alike. showPatternToggle={false}hides the button, for example if you offer a site-wide setting instead.- In Windows High Contrast mode, patterns are always on and the button is hidden, since system colors replace the palette there.
<LineChart
defaultPatterns // or `patterns` + `onPatternsChange` to control it
title="Shooting percentage by month"
data={months}
x="month"
xLabel="Month"
series={[
{ key: "fg", label: "FG%" },
{ key: "three", label: "3P%", dash: "dot" }, // `fill` for bars and areas
]}
/>
Zoom
Add zoomable to a BarChart, LineChart or AreaChart. Drag across the plot to zoom into those categories, move either end with the range slider under the plot, or press + and - on a focused point. "Reset zoom" shows everything again. The value axis rescales to what's in view, and the data table always lists every row.
Accessible by default
- Each chart is a
<figure>named by itstitle. - The plot is one Tab stop. The arrow keys, Home and End move between points (slices, dots, cells), and each one is read out with all its values ("Ridge: Points 71, Rebounds 35").
- Hover and focus show the same values in a tooltip.
- "Show data table" reveals the numbers as a real table.
- In Windows High Contrast mode, up to eight series are told apart by patterns, not color.
Color
Series use the --chart-1 to --chart-8 tokens, a categorical palette checked for color-blind separation in both modes. Colors follow the series order and never change when the data changes. Magnitude (heatmaps, the gauge) uses the one-hue --chart-seq-1 to --chart-seq-7 ramp, which flips in dark mode so low values recede.
Readable
- Bars start at a true zero, so negative values grow downward.
- Axis labels thin out instead of overlapping.
- There's never a second y-axis. For two measures on different scales, use two charts side by side.
- Numbers and dates follow the
LocaleProviderlocale, and the table button is translated.
Props
BarChart
Columns comparing values across categories: one series, grouped series side by side, or stacked series in one bar per category. Bars start at a true zero baseline, and stacked segments are separated by a thin gap.
Accessibility: a <figure> named by its title. The plot is one Tab stop; arrow keys (and Home / End) move between categories, and each one is announced with every value ("Nov 3: Points 72, Rebounds 30"). The same details show in a tooltip on hover and focus. A legend names every series, "Show data table" reveals the numbers as a real table. With patterns on (the patterns prop, or the viewer's "Patterns" button), bars are told apart by hatching and dots as well as color; patterns are always on in Windows High Contrast mode. Choose a series' pattern with its fill.
<BarChart
title="Points per game"
data={games}
x="opponent"
xLabel="Opponent"
series={[{ key: "points", label: "Points" }]}
/>
| Prop | Type | Default |
|---|---|---|
stackedStack the series in one bar per category instead of side by side. The tooltip, point labels, and table add a total. Positive values stack up from zero and negative values down. | boolean | false |
dataRequiredOne row per category (a game, a month), in display order. | readonly T[] | — |
xRequiredThe category of each row: a field name, or a function. | string | ((row: T) => string | number | Date) | — |
xLabelRequiredName of the category, for the table's first column and point labels (e.g. "Game"). | string | — |
formatXFormats a category for axis labels, tooltips, and the table. Dates default to the locale's medium date. | (value: never) => string | — |
seriesRequiredThe measures to plot, in legend order. Colors follow this order (up to 8 series). | readonly ChartSeries<T>[] | — |
formatValueFormats values in tooltips, labels, and the table. | (value: number) => string | the locale's number format |
heightPlot height in px. | number | 280 |
zoomableLet the user zoom into a range of categories: drag across the plot, use the range slider under it, or press + and − on a focused point. "Reset zoom" shows everything again. The value axis rescales to what's in view; the data table always lists every row. | boolean | false |
zoomThe zoomed range (controlled). | ChartZoom | null | — |
defaultZoomInitial zoomed range when uncontrolled. | ChartZoom | null | — |
onZoomChangeCalled with the new range after a zoom, or | (zoom: ChartZoom | null) => void | — |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
LineChart
Lines showing change over an ordered category (usually time). A crosshair follows the pointer and the tooltip lists every series at that point. Up to four series are labeled at their line ends when the labels don't collide. Missing values (null) leave a gap rather than a false line.
Accessibility matches BarChart: one Tab stop, arrow keys between points with spoken values, a legend, a data table, and patterns: with patterns (or the "Patterns" button) each line gets its own dash, always in High Contrast mode. Choose a series' dash with its dash.
| Prop | Type | Default |
|---|---|---|
dataRequiredOne row per category (a game, a month), in display order. | readonly T[] | — |
xRequiredThe category of each row: a field name, or a function. | string | ((row: T) => string | number | Date) | — |
xLabelRequiredName of the category, for the table's first column and point labels (e.g. "Game"). | string | — |
formatXFormats a category for axis labels, tooltips, and the table. Dates default to the locale's medium date. | (value: never) => string | — |
seriesRequiredThe measures to plot, in legend order. Colors follow this order (up to 8 series). | readonly ChartSeries<T>[] | — |
formatValueFormats values in tooltips, labels, and the table. | (value: number) => string | the locale's number format |
heightPlot height in px. | number | 280 |
zoomableLet the user zoom into a range of categories: drag across the plot, use the range slider under it, or press + and − on a focused point. "Reset zoom" shows everything again. The value axis rescales to what's in view; the data table always lists every row. | boolean | false |
zoomThe zoomed range (controlled). | ChartZoom | null | — |
defaultZoomInitial zoomed range when uncontrolled. | ChartZoom | null | — |
onZoomChangeCalled with the new range after a zoom, or | (zoom: ChartZoom | null) => void | — |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
AreaChart
A line with a soft wash down to the baseline: best for one series over time, where the area shows volume. With several series, stacked shows how each adds up to the total (unstacked washes overlap, so prefer a LineChart to compare series). Missing values leave a gap.
Accessibility matches LineChart: one Tab stop, arrow keys between points with spoken values, a legend, a data table, and patterns: hatched fills and dashed lines with patterns or the "Patterns" button (always in High Contrast mode).
| Prop | Type | Default |
|---|---|---|
stackedStack the series, so the top line shows the total and each band one series. | boolean | false |
dataRequiredOne row per category (a game, a month), in display order. | readonly T[] | — |
xRequiredThe category of each row: a field name, or a function. | string | ((row: T) => string | number | Date) | — |
xLabelRequiredName of the category, for the table's first column and point labels (e.g. "Game"). | string | — |
formatXFormats a category for axis labels, tooltips, and the table. Dates default to the locale's medium date. | (value: never) => string | — |
seriesRequiredThe measures to plot, in legend order. Colors follow this order (up to 8 series). | readonly ChartSeries<T>[] | — |
formatValueFormats values in tooltips, labels, and the table. | (value: number) => string | the locale's number format |
heightPlot height in px. | number | 280 |
zoomableLet the user zoom into a range of categories: drag across the plot, use the range slider under it, or press + and − on a focused point. "Reset zoom" shows everything again. The value axis rescales to what's in view; the data table always lists every row. | boolean | false |
zoomThe zoomed range (controlled). | ChartZoom | null | — |
defaultZoomInitial zoomed range when uncontrolled. | ChartZoom | null | — |
onZoomChangeCalled with the new range after a zoom, or | (zoom: ChartZoom | null) => void | — |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
PieChart
A whole split into parts, as slices of a circle. Read at a glance only: people compare angles poorly, so for close values or ranking use a BarChart instead. Keep it to a few parts; past maxSlices (6) the smallest fold into "Other".
Accessibility: a <figure> named by its title. The slices are one Tab stop; arrow keys move between them, and each is announced with its amount and share ("Threes: 24 (32%)"). The legend lists every part with its share, "Show data table" lists every amount (including the parts folded into "Other"). With patterns on (patterns, or the viewer's "Patterns" button), slices are hatched and dotted as well as colored; patterns are always on in High Contrast mode.
<PieChart
title="Points by shot type"
data={shots}
label="type"
value="points"
labelHeader="Shot type"
valueHeader="Points"
/>
| Prop | Type | Default |
|---|---|---|
dataRequiredOne row per part of the whole, in display order (clockwise from 12 o'clock). | readonly T[] | — |
labelRequiredEach part's name: a field name, or a function. | string | ((row: T) => string) | — |
valueRequiredEach part's amount: a field name, or a function. Zero and negative amounts are left out. | string | ((row: T) => number | null | undefined) | — |
labelHeaderRequiredName of the parts, for the table's first column (e.g. "Shot type"). | string | — |
valueHeaderRequiredName of the amounts, for the table's second column (e.g. "Points"). | string | — |
formatValueFormats amounts in tooltips, the legend, and the table. | (value: number) => string | the locale's number format |
maxSlicesMost slices drawn. Past this, the smallest parts fold into one "Other" slice (kept last), since many thin slices can't be read. Up to 8. | number | 6 |
sizeDiameter in px. | number | 240 |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
DonutChart
A pie with a hole that shows the total, or the focused slice's amount and name. Everything else matches PieChart, including its advice: for comparing close values, use a BarChart.
| Prop | Type | Default |
|---|---|---|
dataRequiredOne row per part of the whole, in display order (clockwise from 12 o'clock). | readonly T[] | — |
labelRequiredEach part's name: a field name, or a function. | string | ((row: T) => string) | — |
valueRequiredEach part's amount: a field name, or a function. Zero and negative amounts are left out. | string | ((row: T) => number | null | undefined) | — |
labelHeaderRequiredName of the parts, for the table's first column (e.g. "Shot type"). | string | — |
valueHeaderRequiredName of the amounts, for the table's second column (e.g. "Points"). | string | — |
formatValueFormats amounts in tooltips, the legend, and the table. | (value: number) => string | the locale's number format |
maxSlicesMost slices drawn. Past this, the smallest parts fold into one "Other" slice (kept last), since many thin slices can't be read. Up to 8. | number | 6 |
sizeDiameter in px. | number | 240 |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
ScatterChart
Points on two numeric axes, to show how two measures relate (minutes and points, attempts and percentage). Optional group colors up to three series; the axes start at nice round numbers around the data, not at 0.
Accessibility: a <figure> named by its title. The points are one Tab stop; arrow keys move through them from left to right (Home / End jump to the ends), and each is announced with its name, group, and both values. Hover snaps to the nearest point, so small dots are easy to reach. A legend names the groups, and "Show data table" lists every point. With patterns on (patterns, or the viewer's "Patterns" button), each group's points take their own shape (circle, square, triangle, ...) as well as color, in the plot and the legend; always in High Contrast mode.
<ScatterChart
title="Minutes and points"
data={players}
x="minutes"
y="points"
xLabel="Minutes"
yLabel="Points"
name="player"
nameLabel="Player"
/>
| Prop | Type | Default |
|---|---|---|
dataRequiredOne row per point. | readonly T[] | — |
xRequiredHorizontal value: a field name, or a function. Rows without a number are left out. | string | ((row: T) => number | null | undefined) | — |
yRequiredVertical value: a field name, or a function. | string | ((row: T) => number | null | undefined) | — |
xLabelRequiredName of the horizontal measure, for its axis, point labels, and the table (e.g. "Minutes"). | string | — |
yLabelRequiredName of the vertical measure (e.g. "Points"). | string | — |
groupGroups points into colored series (e.g. a position). Up to three groups get their own color, the most that stay distinct when any two points can sit side by side; more fold into "Other". | string | ((row: T) => string) | — |
groupLabelName of the groups, for the table (e.g. "Position"). Needed with | string | — |
nameEach point's name (e.g. a player), for point labels, tooltips, and the table. | string | ((row: T) => string) | — |
nameLabelName of the points, for the table's first column (e.g. "Player"). Needed with | string | — |
formatXFormats horizontal values. | (value: number) => string | the locale's number format |
formatYFormats vertical values. | (value: number) => string | the locale's number format |
heightPlot height in px. | number | 320 |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
patternsDraw series with patterns as well as color: dashed lines, hatched or dotted bars, areas, and slices, and shaped scatter points. Helps anyone who can't tell the colors apart. Viewers can also switch patterns with the chart's "Patterns" button. They're always on in Windows High Contrast mode. Controlled. | boolean | — |
defaultPatternsInitial pattern state when uncontrolled. | boolean | false |
onPatternsChangeCalled when patterns are switched on or off (by the "Patterns" button). | (patterns: boolean) => void | — |
showPatternToggleShow the "Patterns" toggle button next to "Show data table". | boolean | true |
Heatmap
A grid of cells colored by magnitude (one blue ramp, light to dark; it flips in dark mode so low values recede into the surface). Good for patterns across two categories: minutes by player and quarter, shots by zone and game. The scale above the grid maps colors to values, and showValues prints each number in its cell, in ink chosen for that step.
Accessibility: a <figure> named by its title. The cells are one Tab stop; arrow keys move across and down (Home / End: the row's ends; Ctrl+Home / Ctrl+End: the first and last cells), and each cell is announced with its row, column, and value. "Show data table" shows the same grid as a real table, so color is never the only way in.
<Heatmap
title="Points by quarter"
data={rows}
x="quarter"
y="player"
value="points"
yLabel="Player"
valueLabel="Points"
/>
| Prop | Type | Default |
|---|---|---|
dataRequiredOne row per cell: its column, its row, and its value. | readonly T[] | — |
xRequiredThe cell's column: a field name, or a function. Columns keep their first-seen order. | string | ((row: T) => string | number | Date) | — |
yRequiredThe cell's row: a field name, or a function. Rows keep their first-seen order. | string | ((row: T) => string | number | Date) | — |
valueRequiredThe cell's value: a field name, or a function. Missing cells are drawn empty. | string | ((row: T) => number | null | undefined) | — |
yLabelRequiredName of the rows, for the table's first column (e.g. "Player"). | string | — |
valueLabelRequiredName of the values, for the scale and tooltips (e.g. "Points"). | string | — |
formatXFormats column names. Dates default to the locale's medium date. | (value: never) => string | — |
formatYFormats row names. | (value: never) => string | — |
formatValueFormats values. | (value: number) => string | the locale's number format |
showValuesPrint each value in its cell, where it fits. | boolean | false |
minValue at the light end of the scale. | number | the smallest value |
maxValue at the dark end of the scale. | number | the largest value |
cellHeightCell height in px. | number | 36 |
titleRequiredTitle: names the figure, captions the table, and is shown above the chart. | string | — |
descriptionOne-sentence takeaway shown under the title (and read with the figure). | ReactNode | — |
hideTitleHide the title visually (it still names the figure), when a heading nearby already says it. | boolean | false |
showTableShow the data table (controlled). | boolean | — |
defaultShowTableShow the data table initially when uncontrolled. | boolean | false |
onShowTableChangeCalled when the table is shown or hidden. | (show: boolean) => void | — |
classNameClass name for the | string | — |
styleStyle for the | CSSProperties | — |
Gauge
A half-circle dial for one value within a known range (a percentage, a score against a cap). The filled arc grows from the start along a lighter track of the same blue ramp; the number itself is printed large in the middle, so the dial is never the only way to read it. An optional target adds a tick on the dial and a line of text. For a single ratio in a tight space, a Progress bar is simpler; for several values, use a BarChart.
Accessibility: role="meter" named by label, with aria-valuenow, aria-valuemin, aria-valuemax, and the formatted value as aria-valuetext. The drawing is hidden from assistive technology.
<Gauge label="Free throw percentage" value={76} target={80} formatValue={(v) => `${v}%`} />
| Prop | Type | Default |
|---|---|---|
valueRequiredThe current value. Clamped to | number | — |
minLowest value on the dial. | number | 0 |
maxHighest value on the dial. | number | 100 |
labelRequiredWhat it measures (e.g. "Free throw percentage"). Shown under the value and names the meter. | string | — |
targetA goal to mark on the dial, with its value under the label. | number | — |
formatValueFormats the value, the ends, and the target. | (value: number) => string | the locale's number format |
sizeWidth in px; the height is a little over half. | number | 220 |
Also accepts native <div> attributes, plus className, style and ref.
Sparkline
A word-sized trend line for stat tiles, tables, and lists: no axes, the trend in a quiet ink, and the latest value marked in the accent series color. Pair it with the number it trends (a Stat), since a sparkline shows shape, not values.
Accessibility: one image whose name summarizes the series ("Points: from 58 to 72, low 55, high 80"), so it reads well inside a table cell or tile.
<Sparkline label="Points" data={[58, 64, 61, 72]} />
| Prop | Type | Default |
|---|---|---|
dataRequiredThe values, oldest first. | readonly (number | null)[] | — |
labelRequiredWhat the values measure (e.g. "Points"). Starts the accessible name. | string | — |
variant
| "line""area""bar" | "line" |
widthWidth in px. | number | 96 |
heightHeight in px. | number | 24 |
formatValueFormats values in the accessible name. | (value: number) => string | the locale's number format |
aria-labelOverrides the generated accessible name ("Points: from 58 to 72, low 55, high 80"). | string | — |
Also accepts native <svg> attributes, plus className, style and ref.
ChartSeries
One plotted measure: a key into each row (or a value function) and its name.
| Prop | Type | Default |
|---|---|---|
keyRequiredUnique key. Also the field read from each row when there is no | string | — |
labelRequiredName shown in the legend, tooltip, table, and spoken point labels. | string | — |
valueReads the value from a row. | (row: T) => number | null | undefined | (row) => row[key] |
dashLine style while patterns are on ( | "solid""dash""dot""dash-dot""long-dash""dash-dot-dot""long-dash-dot""short-dash" | — |
fillFill while patterns are on ( | "solid""diagonal""dots""crosshatch""horizontal""reverse-diagonal""vertical""grid" | — |
ChartZoom
The categories in view after zooming: indexes into data, both inclusive.
| Prop | Type | Default |
|---|---|---|
startRequired | number | — |
endRequired | number | — |