Skip to content
العربية
Charts

AreaChart

Values over time as filled areas, side by side or stacked to show the total. limit draws a dashed line with its label; a value at 90 % of the limit or more shows in the warning colour. With onSelectPoint, a click or Enter on the chosen point opens it. On touch, the first tap shows the value and a second tap on the same point opens it. The limit label has a halo in --p-chart-surface (default the page colour; Card sets it to its own surface), so it stays readable over the area.

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

Examples

  • Website
  • App
  • Store
Visits by channel
MonthWebsiteAppStore
Jan1,200800300
Feb1,500900350
Mar1,4001,300320
Apr1,9001,500400
May2,3001,700380
Jun2,6002,100450
Code
export function AreaChartExample() {
  const t = useT();
  const lang = useLang();
  const web = [1200, 1500, 1400, 1900, 2300, 2600];
  const app = [800, 900, 1300, 1500, 1700, 2100];
  const store = [300, 350, 320, 400, 380, 450];
  return (
    <AreaChart
      className="w-full"
      title={t("Visits by channel", "الزيارات حسب القناة")}
      data={MONTHS[lang].map((month, i) => ({ month, web: web[i]!, app: app[i]!, store: store[i]! }))}
      x="month"
      xLabel={t("Month", "الشهر")}
      series={[
        { key: "web", label: t("Website", "الموقع") },
        { key: "app", label: t("App", "التطبيق") },
        { key: "store", label: t("Store", "المتجر") },
      ]}
      curve="monotone"
      stacked
    />
  );
}
Memory use
TimeMemory (GB)
10:000.21
10:050.24
10:100.3
10:150.33
10:200.38
10:250.41
10:300.47
10:350.44
10:400.36
10:450.29

Limit 0.5 GB

Code
export function AreaChartLimitExample() {
  const t = useT();
  const memory = [0.21, 0.24, 0.3, 0.33, 0.38, 0.41, 0.47, 0.44, 0.36, 0.29];
  return (
    <AreaChart
      className="w-full"
      title={t("Memory use", "استخدام الذاكرة")}
      data={memory.map((v, i) => ({ minute: `10:${String(i * 5).padStart(2, "0")}`, memory: v }))}
      x="minute"
      xLabel={t("Time", "الوقت")}
      series={[{ key: "memory", label: t("Memory (GB)", "الذاكرة (GB)") }]}
      curve="monotone"
      limit={{ value: 0.5, label: t("Limit 0.5 GB", "الحد: \u20660.5 GB\u2069") }}
    />
  );
}