Computing for good
Atlanta Food Consortium/Feature Docs

BarChartComponent

A paginated bar chart that supports both horizontal and vertical layouts. Built on Recharts.

Overview

BarChartComponent renders a bar chart with built-in pagination for long datasets. It supports both vertical (default) and horizontal layouts. Used in the Admin Dashboard to show top suppliers by donation volume.

Props

PropTypeRequiredDescription
dataobject[]YesArray of data objects.
dataKeystringYesKey in each object used for the bar value.
xAxisKeystringYesKey used for axis labels.
titlestringNoTitle above the chart.
descriptionstringNoSubtitle below the title.
layout'horizontal' | 'vertical'NoBar orientation. Default: 'vertical'.
itemsPerPagenumberNoHow many bars to show per page. Default: 5.
barColorstringNoFill colour for bars.

Usage

import BarChartComponent from '@/components/charts/BarChartComponent';

const data = [
  { name: 'Whole Foods', donated: 320 },
  { name: 'Kroger', donated: 210 },
  { name: 'Publix', donated: 180 },
];

<BarChartComponent
  data={data}
  dataKey='donated'
  xAxisKey='name'
  title='Top Suppliers'
  itemsPerPage={5}
/>;

Info: Pagination When data.length > itemsPerPage, Previous/Next buttons appear below the chart. The component manages page state internally - no external state needed.

Source file: src/components/charts/BarChartComponent.tsx