AreaChart

Filled area chart with zero-anchored domain and optional stacking.

Import

import { AreaChart } from '@matix/charts/area-chart';

Usage

Data for Traffic
SeriesXValue
Traffic:020.
Traffic:145.
Traffic:230.
Traffic:355.
Traffic:448.

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.

Data for Orders
SeriesXValue
Orders:014.
Orders:122.
Orders:218.
Orders:327.
Orders:423.

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.

Data for Revenue
SeriesXValue
Revenue:Jun156.
Revenue:Jul163.
Revenue:Aug158.
Revenue:Sep171.
Revenue:Oct185.
Revenue:Nov192.

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.

Data for Visitors
SeriesXValue
Visitors:Mon186.
Visitors:Tue305.
Visitors:Wed237.
Visitors:Thu273.
Visitors:Fri209.

Stacked

Set stacked to accumulate series into bands. All series must share the same x values, aligned by index.

Data for Desktop, Mobile
SeriesXValue
Desktop:012.
Desktop:118.
Desktop:215.
Desktop:322.
Mobile:08.
Mobile:114.
Mobile:219.
Mobile:317.

API Reference

PropTypeDefaultDescription
seriesChartSeries[]—One or more series to plot
stackedbooleanfalseStack series into bands (shared x)
widthnumber—Controlled layout width; enables deterministic SSR
initialWidthnumber—SSR width hint replaced by client measurement
heightnumber280Plot height in px
curve'straight' | 'curved''curved'Interpolation between points
fill'solid' | 'opaque' | 'gradient''gradient'Fill treatment for the bands
fillOpacitynumber | [top, bottom]0.15 opaque, [0.35, 0] gradientFill opacity, 0–1; a pair sets both gradient stops
showXAxisbooleantrueShow the bottom axis
showYAxisbooleantrueShow the left axis
showGridbooleantrueShow horizontal grid lines
showTooltipbooleantrueHover crosshair + tooltip
showLegendbooleantrueLegend (renders only with ≥ 2 series)
animatebooleantrueFill and edge reveal together on mount; respects reduced-motion
maxPointsnumber—LTTB downsampling budget override
yDomain[number, number]—Force the y domain; out-of-range marks are clipped
formattersChartFormatters—Format values, x values, and series/category labels
labelstring—Accessible description (defaults to series labels)
labelsChartLabels—Screen-reader text of the data table and the legend, for translation
showLabelbooleanfalseRender label as a visible title above the plot
sxStyleXStyles—StyleX style override

Accessibility

  • label provides the concise image name. description adds a richer summary through aria-describedby; consumer-owned text or a visible table can be linked with the aria-describedby prop.
  • Datasets up to 20 rows / 100 cells receive a visually hidden native data table. accessibleData replaces that table with custom React content; pass null to suppress it. labels translates 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.