Skip to content
Alea0.1

Charts

LineChart and AreaChart

Values over time, smooth or straight, with areas, stacking, a tooltip and a data table view.

Ant Design: Line, Area (Ant Charts)

import { LineChart, AreaChart } from '@alea/ui';

Examples

Lines over time

Hover, or Tab to the chart and use the arrow keys, to read each month. The table button shows the same data as a table.

Visits and sign-ups

Both grew every month since August.

  • Visits
  • Sign-ups
02,5005,0007,50010,000MayJunJulAugSepOct

Stacked area

Parts of a whole over time: traffic by source.

Traffic by source
  • Direct
  • Search
  • Social
05001,0001,500MonTueWedThuFriSatSun

Props

LineChart props

Values over time. Hover or use the arrow keys (after Tab) to read each point (MUI LineChart, Mantine LineChart).

PropTypeDefaultDescription
datarequiredChartRow[]-Rows of data, one per x value or category.
seriesrequiredSeries[]-The series to draw: key in each row, label for the legend, optional color.
xrequiredstring-The key for the x axis (dates, months, categories).
areaboolean-Fill under the lines (an area chart).
classNamestring-Extra class names for the root element.
curve"smooth" | "linear"'smooth'smooth (default) or straight lines.
descriptionReactNode-One sentence on what the data shows; read before the chart.
heightnumber260Plot height in px. Default 260.
showDotsboolean-Dots on each point.
showTablebooleantrueShows the table toggle. Default true.
stackedboolean-Stack the areas on top of each other.
titleReactNode-The title shown above it and read by screen readers.
valueFormat((v: number) => string)-Formats values (axis, tooltip, table).
xFormat((x: string | number) => string)-Formats x labels.
zeroBasedbooleantrueStart the y axis at zero. Default true.

AreaChart props

A LineChart filled underneath; stacked shows parts of a whole over time.

PropTypeDefaultDescription
datarequiredChartRow[]-Rows of data, one per x value or category.
seriesrequiredSeries[]-The series to draw: key in each row, label for the legend, optional color.
xrequiredstring-The key for the x axis (dates, months, categories).
classNamestring-Extra class names for the root element.
curve"smooth" | "linear"-smooth (default) or straight lines.
descriptionReactNode-One sentence on what the data shows; read before the chart.
heightnumber-Plot height in px. Default 260.
showDotsboolean-Dots on each point.
showTableboolean-Shows the table toggle. Default true.
stackedboolean-Stack the areas on top of each other.
titleReactNode-The title shown above it and read by screen readers.
valueFormat((v: number) => string)-Formats values (axis, tooltip, table).
xFormat((x: string | number) => string)-Formats x labels.
zeroBasedboolean-Start the y axis at zero. Default true.

Accessibility

  • A figure with a title and description; the chart itself is an image named with a summary (from, to, highest).
  • Tab to the chart, then arrows read each point aloud.
  • Every chart can switch to a real data table.

Keyboard

KeyDoes
TabFocuses the chart
Arrow Left / RightRead the previous or next point
Home / EndFirst or last point
EscapeHides the tooltip

Do and don't

Do

  • Write the description as the takeaway: "Visits doubled after the launch".
  • Keep it to four series or fewer.

Don't

  • Don't rely on color alone: name the series in the legend.

In Figma

Chart frames with the same palette variables (chart/1 to chart/8).

Tested with axe, keyboard and screen reader roles