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
| Month | Website | App | Store |
|---|---|---|---|
| Jan | 1,200 | 800 | 300 |
| Feb | 1,500 | 900 | 350 |
| Mar | 1,400 | 1,300 | 320 |
| Apr | 1,900 | 1,500 | 400 |
| May | 2,300 | 1,700 | 380 |
| Jun | 2,600 | 2,100 | 450 |
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
/>
);
}| Time | Memory (GB) |
|---|---|
| 10:00 | 0.21 |
| 10:05 | 0.24 |
| 10:10 | 0.3 |
| 10:15 | 0.33 |
| 10:20 | 0.38 |
| 10:25 | 0.41 |
| 10:30 | 0.47 |
| 10:35 | 0.44 |
| 10:40 | 0.36 |
| 10:45 | 0.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") }}
/>
);
}