BarChart

A vertical bar chart for comparing values across categories, with optional stacking.

Installation

npx dafink-ui add bar-chart

Requires: recharts

Demo

Props

NameTypeDefaultDescription
dataChartDataPoint[]-Array of data objects.
xKeystring-Key to use as the x-axis label.
seriesChartSeries[]-Bar groups to render.
stackedbooleanfalseStack series on top of each other.
heightnumber240Chart height in px.
showLegendbooleantrueWhether to show the legend.
showGridbooleantrueWhether to show the background grid.
classNamestring""Extra classes applied to the container.

Accessibility

BarChart shares the same Recharts accessibility layer as the other charts: Tab focuses the SVG, ArrowLeft/ArrowRight step a shared tooltip across each category's bar group, and Enter pins it. Unlike the other four charts here, BarChart doesn't wrap its container in role="img"/aria-label — its accessible name instead comes from a title prop passed straight into Recharts, which renders it as the SVG's own <title>element ("Bar chart"). Hovering or keyboard-focusing a category also slightly darkens its bars; the legend is static, not clickable.