Skip to content
العربية
Charts

ChartLegend

Names the series with the same line or fill as the chart. Charts with more than one series show it by themselves.

import { ChartLegend } from "@percentsa/ui";

Examples

  • Website
  • App
  • Store
  • Partners
  • New62%
  • Waiting for reply38%
Code
export function ChartLegendExample() {
  const t = useT();
  const lang = useLang();
  const pct = (n: number) => formatNumber(n, lang, { style: "percent" });
  return (
    <div className="grid gap-4">
      <ChartLegend items={[{ label: t("Website", "الموقع") }, { label: t("App", "التطبيق") }, { label: t("Store", "المتجر") }, { label: t("Partners", "الشركاء") }]} />
      <ChartLegend
        kind="fill"
        items={[
          { label: t("New", "جديدة"), value: pct(0.62) },
          { label: t("Waiting for reply", "بانتظار الرد"), value: pct(0.38) },
        ]}
      />
    </div>
  );
}