Playground

Area chart

A line chart filled down to zero, optionally stacked to show a running total.

  • Built on native elements
  • The chart is role=img with the required title as its name.
  • A visually hidden table lists every value, one row per category, for screen readers.
  • One focusable stop per category with a spoken label; Arrow keys move between them and Escape hides the tooltip.
  • Styles in one file: chart.css

Import

import '@monoline/css';
import {AreaChart} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add area-chart

Usage

import {AreaChart} from '@monoline/react';

const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'];

<AreaChart
  title="Active users"
  labels={months}
  series={[{name: 'Users', values: [120, 180, 150, 240, 310, 290]}]}
/>

Examples

Single series

Stacked

Stepped

Props

AreaChartProps

PropTypeDefaultDescription
stackedboolean–Stack series on top of each other so the top edge is the running total.
showPointsboolean–Mark each data point. A single point is always marked.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-active]chart.css
[data-align="end"]chart.css
[data-align="start"]chart.css

CSS classes

ClassStylesheet
.chartchart.css
.chart-areachart.css
.chart-emptychart.css
.chart-hitchart.css
.chart-hitschart.css
.chart-legendchart.css
.chart-legend-detailchart.css
.chart-linechart.css
.chart-markschart.css
.chart-outlinechart.css
.chart-patchart.css
.chart-pat-dotchart.css
.chart-plotchart.css
.chart-rulechart.css
.chart-s0chart.css
.chart-s1chart.css
.chart-s2chart.css
.chart-s3chart.css
.chart-s4chart.css
.chart-svgchart.css
.chart-swatchchart.css
.chart-tickchart.css
.chart-tipchart.css
.chart-tip-rowchart.css
.chart-tip-titlechart.css
.chart-tip-valuechart.css
.chart-valuechart.css
.chart-zerochart.css
.chart-guideline-chart.css
.chart-pointline-chart.css
.chart-areaarea-chart.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.chart {
  border-color: var(--accent);
}
.chart[data-active] {
  background: var(--wash);
}

Accessibility

  • The chart is role=img with the required title as its name.
  • A visually hidden table lists every value, one row per category, for screen readers.
  • One focusable stop per category with a spoken label; Arrow keys move between them and Escape hides the tooltip.
  • The value tooltip opens on hover and on keyboard focus; stacked charts also show the total.
  • Series differ by fill pattern and dash as well as colour, and the legend names them.
  • No entrance animation under prefers-reduced-motion.

Keyboard

KeysAction
Arrow keysMove between them and Escape hides the tooltip