"use client"; import type * as React from "react"; import { Bar, BarChart, XAxis } from "recharts"; import { CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/components/ui/chart"; import { Delta, DeltaIcon, DeltaValue } from "@/components/delta"; import { DashboardCard } from "@/components/dashboard-card"; import { formatDate } from "@/components/formater"; import type { PovertyOverview } from "@/lib/poverty-types"; interface HouseholdsTrendChartProps { monthly: PovertyOverview["monthly"]; } const chartConfig = { count: { label: "KK Terdata", color: "var(--chart-2)", }, } satisfies ChartConfig; function CustomGradientBar( props: React.SVGProps & { index?: number; dataKey?: string | number; } ) { const { fill, x = 0, y = 0, width = 0, height = 0, dataKey = "count", index = 0, } = props; const gid = `gradient-bar-${String(dataKey)}-${index}`; return ( <> ); } export function HouseholdsTrendChart({ monthly }: HouseholdsTrendChartProps) { const chartRows = monthly.map((m) => ({ month: m.month, count: m.count })); const first = chartRows[0]?.count ?? 0; const last = chartRows.at(-1)?.count ?? 0; const growthPct = first > 0 ? ((last - first) / first) * 100 : 0; return (
Pendataan Warga {chartRows.length > 1 && ( )}
KK baru terdata per bulan, 12 bulan terakhir.
{chartRows.length === 0 ? (
Belum ada data pendataan warga.
) : ( formatDate(`${value}-01`, "month")} tickLine={false} tickMargin={10} /> } cursor={false} /> } /> )}
); }