About
KPI card whose area chart draws itself in, flags the peak and counts the total up. Period tabs, keyboard scrubbing, RTL + Intl ready.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds summit-chart to your project and fits it to your theme.
Code
How summit-chart is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import * as React from "react";
import { SummitChart, type SummitPeriod } from "@/components/ui/summit-chart";
type Lang = "en" | "fr" | "ar";
// Booking revenue of a small riad in Marrakech, in Moroccan dirhams.
const WEEK = [6420, 7180, 6950, 9860, 14240, 12610, 8930];
const MONTH = [
4210, 3980, 4460, 5120, 6890, 7340, 5010, 4380, 4120, 4650, 5230, 7180, 7920, 5460, 4870, 4590, 5340, 6120, 8460,
9120, 10840, 12460, 9380, 6210, 5480, 5960, 6740, 8110, 8870, 6420,
];
const YEAR = [118400, 131200, 164900, 212300, 186700, 142100, 128800, 151600, 173400, 226900, 197200, 168300];
const TEXT = {
en: {
locale: "en-US",
title: "Booking revenue",
description: "Riad Dar Lmasa · Marrakech",
peak: "Peak",
tabs: ["Week", "Month", "Year"],
vs: ["vs last week", "vs October", "vs 2024"],
},
fr: {
locale: "fr-MA",
title: "Revenus des réservations",
description: "Riad Dar Lmasa · Marrakech",
peak: "Pic",
tabs: ["Semaine", "Mois", "Année"],
vs: ["vs semaine dernière", "vs octobre", "vs 2024"],
},
ar: {
locale: "ar-MA",
title: "إيرادات الحجوزات",
description: "رياض دار لماسة · مراكش",
peak: "الذروة",
tabs: ["أسبوع", "شهر", "سنة"],
vs: ["مقارنة بالأسبوع الماضي", "مقارنة بأكتوبر", "مقارنة بـ 2024"],
},
} as const;
function buildPeriods(lang: Lang): SummitPeriod[] {
const t = TEXT[lang];
const day = new Intl.DateTimeFormat(t.locale, { weekday: "short" });
const date = new Intl.DateTimeFormat(t.locale, { day: "numeric", month: "short" });
const month = new Intl.DateTimeFormat(t.locale, { month: "short" });
return [
{
id: "week",
label: t.tabs[0],
points: WEEK.map((value, i) => ({ value, label: day.format(new Date(2025, 10, 17 + i)) })),
change: 18.4,
comparisonLabel: t.vs[0],
},
{
id: "month",
label: t.tabs[1],
points: MONTH.map((value, i) => ({ value, label: date.format(new Date(2025, 10, 1 + i)) })),
change: -2.3,
comparisonLabel: t.vs[1],
},
{
id: "year",
label: t.tabs[2],
points: YEAR.map((value, i) => ({ value, label: month.format(new Date(2025, i, 1)) })),
change: 24.6,
comparisonLabel: t.vs[2],
},
];
}
const LANGS: { id: Lang; label: string }[] = [
{ id: "en", label: "English" },
{ id: "fr", label: "Français" },
{ id: "ar", label: "العربية" },
];
export default function SummitChartDemo() {
const [lang, setLang] = React.useState<Lang>("en");
const [period, setPeriod] = React.useState("week");
const t = TEXT[lang];
const periods = React.useMemo(() => buildPeriods(lang), [lang]);
return (
<div className="flex min-h-[640px] w-full flex-col items-center justify-center gap-5 bg-background p-6">
<div role="radiogroup" aria-label="Language" className="flex gap-1 rounded-full border border-border bg-card p-1 text-xs">
{LANGS.map((l) => (
<button
key={l.id}
type="button"
role="radio"
aria-checked={lang === l.id}
onClick={() => setLang(l.id)}
className={`rounded-full px-3 py-1 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${
lang === l.id ? "bg-foreground text-background" : "text-muted-foreground hover:text-foreground"
}`}
>
{l.label}
</button>
))}
</div>
<div dir={lang === "ar" ? "rtl" : "ltr"} lang={lang} className="flex w-full justify-center">
<SummitChart
title={t.title}
description={t.description}
periods={periods}
periodId={period}
onPeriodChange={setPeriod}
locale={t.locale}
formatOptions={{ style: "currency", currency: "MAD", maximumFractionDigits: 0 }}
peakLabel={t.peak}
/>
</div>
</div>
);
}









