import { PieChart, Pie, Cell, ResponsiveContainer } from 'recharts'; import { cn } from "@/lib/utils"; interface SpendingCategory { name: string; value: number; color: string; } interface SpendingAnalyticsProps { data: SpendingCategory[]; currency?: string; } const SpendingAnalytics = ({ data, currency = "$" }: SpendingAnalyticsProps) => { const totalSpending = data.reduce((sum, item) => sum + item.value, 0); const formatCurrency = (amount: number) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', currencyDisplay: 'symbol', }).format(amount).replace('$', ''); }; return (

Spending by Category

{data.map((entry, index) => ( ))}
{data.map((category, index) => (
{category.name}
{currency}{formatCurrency(category.value)} {Math.round((category.value / totalSpending) * 100)}%
))}
); }; export default SpendingAnalytics;