AreaChart
Filled area chart with zero-anchored domain and optional stacking.
Import
import { AreaChart } from '@matix/charts/area-chart';Usage
| Series | X | Value |
|---|---|---|
| Traffic: | 0 | 20. |
| Traffic: | 1 | 45. |
| Traffic: | 2 | 30. |
| Traffic: | 3 | 55. |
| Traffic: | 4 | 48. |
Fills
fill controls how the band under each line looks: gradient (default) fades the series color out toward the baseline, opaque is a uniform low-opacity wash, and solid is a step lighter than the line with no transparency.
| Series | X | Value |
|---|---|---|
| Orders: | 0 | 14. |
| Orders: | 1 | 22. |
| Orders: | 2 | 18. |
| Orders: | 3 | 27. |
| Orders: | 4 | 23. |
Category x values
Give x as a string to plot categories, such as month names. The chart puts the categories at equal intervals, in the order that the data first uses them. formatters.category formats them on the axis and in the tooltip.
| Series | X | Value |
|---|---|---|
| Revenue: | Jun | 156. |
| Revenue: | Jul | 163. |
| Revenue: | Aug | 158. |
| Revenue: | Sep | 171. |
| Revenue: | Oct | 185. |
| Revenue: | Nov | 192. |
Fill opacity
fillOpacity sets how strong the fill is. A number sets the opaque fill and the top of the gradient fill. A [top, bottom] pair sets both ends of the gradient. This example matches the lighter shadcn/ui gradient.
| Series | X | Value |
|---|---|---|
| Visitors: | Mon | 186. |
| Visitors: | Tue | 305. |
| Visitors: | Wed | 237. |
| Visitors: | Thu | 273. |
| Visitors: | Fri | 209. |
Stacked
Set stacked to accumulate series into bands. All series must share the same x values, aligned by index.
| Series | X | Value |
|---|---|---|
| Desktop: | 0 | 12. |
| Desktop: | 1 | 18. |
| Desktop: | 2 | 15. |
| Desktop: | 3 | 22. |
| Mobile: | 0 | 8. |
| Mobile: | 1 | 14. |
| Mobile: | 2 | 19. |
| Mobile: | 3 | 17. |
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
series | ChartSeries[] | — | One or more series to plot |
stacked | boolean | false | Stack series into bands (shared x) |
width | number | — | Controlled layout width; enables deterministic SSR |
initialWidth | number | — | SSR width hint replaced by client measurement |
height | number | 280 | Plot height in px |
curve | 'straight' | 'curved' | 'curved' | Interpolation between points |
fill | 'solid' | 'opaque' | 'gradient' | 'gradient' | Fill treatment for the bands |
fillOpacity | number | [top, bottom] | 0.15 opaque, [0.35, 0] gradient | Fill opacity, 0–1; a pair sets both gradient stops |
showXAxis | boolean | true | Show the bottom axis |
showYAxis | boolean | true | Show the left axis |
showGrid | boolean | true | Show horizontal grid lines |
showTooltip | boolean | true | Hover crosshair + tooltip |
showLegend | boolean | true | Legend (renders only with ≥ 2 series) |
animate | boolean | true | Fill and edge reveal together on mount; respects reduced-motion |
maxPoints | number | — | LTTB downsampling budget override |
yDomain | [number, number] | — | Force the y domain; out-of-range marks are clipped |
formatters | ChartFormatters | — | Format values, x values, and series/category labels |
label | string | — | Accessible description (defaults to series labels) |
labels | ChartLabels | — | Screen-reader text of the data table and the legend, for translation |
showLabel | boolean | false | Render label as a visible title above the plot |
sx | StyleXStyles | — | StyleX style override |
Accessibility
labelprovides the concise image name.descriptionadds a richer summary througharia-describedby; consumer-owned text or a visible table can be linked with thearia-describedbyprop.- Datasets up to 20 rows / 100 cells receive a visually hidden native data table.
accessibleDatareplaces that table with custom React content; passnullto suppress it.labelstranslates the table text and the legend name. Large series require a consumer-provided summary or table. - The chart remains one image target rather than making every point focusable.
- Tooltip rows always report a series' own value, never the cumulative stack total.
- The series reveal is disabled under
prefers-reduced-motion. - The pointer tooltip is supplemental; the hidden or consumer-provided data representation carries its values for assistive technology.
Series palette slots follow input order by default. Set colorIndex (0–7) on a ChartSeries when a series must keep the same token color after insertion or reordering.
Data contract
Each series must use one x-value type (number, Date, or string). Numbers and Dates must be finite and sorted in ascending order. Strings are categories in display order; a series must not repeat a category. Give every series the same categories in the same order: a category that only a later series uses goes after the others. Stacked series must have equal lengths and matching x values at every index. Development builds warn on violations; non-finite y values normalize to gaps.
Server rendering
Pass width for deterministic server-rendered SVG. Use initialWidth when the server has a layout estimate but the chart should become container-responsive after hydration. Without either prop, the wrapper still reserves height, then renders the SVG after ResizeObserver reports a width.