Charts
DonutChart
Parts of a whole, with a total in the centre and a legend with percentages. Use it for five parts or fewer.
import { DonutChart } from "@percentsa/ui";Examples
9,000Visits
- Search46.7%
- Direct28.9%
- Social16.7%
- Email7.8%
| Category | Visits by source |
|---|---|
| Search | 4,200 |
| Direct | 2,600 |
| Social | 1,500 |
| 700 |
Code
export function DonutChartExample() {
const t = useT();
return (
<DonutChart
className="w-full"
title={t("Visits by source", "الزيارات حسب المصدر")}
data={[
{ label: t("Search", "البحث"), value: 4200 },
{ label: t("Direct", "مباشر"), value: 2600 },
{ label: t("Social", "التواصل الاجتماعي"), value: 1500 },
{ label: t("Email", "البريد"), value: 700 },
]}
value={formatNumber(9000, useLang())}
label={t("Visits", "زيارة")}
/>
);
}