Charts

Dependency-free React SVG charts using the DGA categorical palette: BarChart, LineChart, and PieChart, each with an accessible table fallback and RTL support.

The three charts share one API: pass data for pie, or series + categories for bar and line. Each renders an accessible table fallback.

When to use

Use BarChart to compare categories, LineChart for change over time, and PieChart for a small number of shares of a whole. Pass series and categories for bar and line, or data for pie.

Keep series counts low so the categorical colors stay distinguishable. For a single headline number, use Metric.

Examples

Bar chart

Line chart

Pie chart

Props

Props declared by Charts. Native attributes of the underlying element pass through.

<BarChart>

PropTypeDefaultDescription
palettePaletteColour set: DGA categorical (default) or the monochrome brand-green sequence.
legendbooleantrueShow the legend.
titlestringAccessible name for the chart (also the data-table caption).
seriesrequiredChartSeries[]
categoriesrequiredstring[]
xAxisLabelstringX-axis title.
yAxisLabelstringY-axis title (rotated).
yMaxnumberForce the Y-axis maximum (default: auto, rounded to a nice value).
widthnumberviewBox width / height. Charts scale responsively to their container.
heightnumber
stackedbooleanStack series into one column per category (default). false groups them side by side.

<LineChart>

PropTypeDefaultDescription
palettePaletteColour set: DGA categorical (default) or the monochrome brand-green sequence.
legendbooleantrueShow the legend.
titlestringAccessible name for the chart (also the data-table caption).
seriesrequiredChartSeries[]
categoriesrequiredstring[]
xAxisLabelstringX-axis title.
yAxisLabelstringY-axis title (rotated).
yMaxnumberForce the Y-axis maximum (default: auto, rounded to a nice value).
widthnumberviewBox width / height. Charts scale responsively to their container.
heightnumber
areabooleantrueDraw a soft area gradient under each line.
curve"linear" | "smooth"A smooth Catmull-Rom curve (SDGA "Gradual" default) or straight segments.

<PieChart>

PropTypeDefaultDescription
palettePaletteColour set: DGA categorical (default) or the monochrome brand-green sequence.
legendbooleantrueShow the legend.
titlestringAccessible name for the chart (also the data-table caption).
datarequiredChartSlice[]
donutbooleanRender a donut (50% hole) instead of a full pie.
sizenumber240Disk diameter in px.

Accessibility

Each chart renders role="img" with an accessible name and a visually hidden data table, so screen reader users get the actual values.

Colors come from the DGA categorical scale, and legends use text labels, not color alone. Axes and labels follow the page direction in RTL.