Skip to content
العربية
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%
Visits by source
CategoryVisits by source
Search4,200
Direct2,600
Social1,500
Email700
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", "زيارة")}
    />
  );
}