Computing for good
Atlanta Food Consortium/Feature Docs

DonutChartComponent

A donut (ring) chart for displaying proportional breakdowns. Built on Recharts.

Overview

DonutChartComponent renders a donut chart with a center label. Used in the Admin Dashboard to visualize product category distribution and other proportional data.

Props

PropTypeRequiredDescription
dataDataItem[]YesArray of segments - each with name, value, and optional fill.
titlestringNoTitle above the chart.
descriptionstringNoSubtitle below the title.
innerRadiusnumberNoInner hole radius in pixels. Default: 60.
outerRadiusnumberNoOuter ring radius in pixels. Default: 100.

Data shape

type DataItem = {
  name: string; // Segment label shown in the legend
  value: number; // Segment size
  fill?: string; // Optional hex color - falls back to default palette
};

Usage

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

const data = [
  { name: 'Produce', value: 34, fill: '#10b981' },
  { name: 'Protein', value: 22, fill: '#3b82f6' },
  { name: 'Dairy', value: 18, fill: '#f59e0b' },
  { name: 'Other', value: 26 },
];

<DonutChartComponent
  data={data}
  title='Products by Category'
  description='Distribution of active listings'
/>;

Default color palette

If fill is omitted, segments cycle through the chart's internal default palette (#3b82f6, #10b981, #f59e0b, #ef4444, #8b5cf6, …).

Mobile behavior

Slice labels are hidden on viewports narrower than sm (640 px) to prevent overlap. Only the legend is shown on small screens.

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