'use client'; import { FeatureCardContainer } from '@/components/feature-card'; import { MoreVerticalIcon } from 'lucide-react'; import { useMemo, useState } from 'react'; import { Bar, CartesianGrid, Cell, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; // Sample data for the last 7 days const data = [ { day: 'Mon', visitors: 1200, revenue: 1250 }, { day: 'Tue', visitors: 1450, revenue: 1890 }, { day: 'Wed', visitors: 1320, revenue: 1520 }, { day: 'Thu', visitors: 1580, revenue: 2100 }, { day: 'Fri', visitors: 1420, revenue: 1750 }, { day: 'Sat', visitors: 1180, revenue: 1100 }, { day: 'Sun', visitors: 1250, revenue: 1380 }, ]; // Custom tooltip component const CustomTooltip = ({ active, payload, label }: any) => { if (active && payload && payload.length) { const visitors = payload.find((p: any) => p.dataKey === 'visitors')?.value || 0; const revenue = payload.find((p: any) => p.dataKey === 'revenue')?.value || 0; return (
{label}
Visitors {visitors.toLocaleString()}
Revenue ${revenue.toLocaleString()}
); } return null; }; export function CollaborationChart() { const [activeIndex, setActiveIndex] = useState(1); // Default to Tue (index 1) // Calculate metrics from active point or default const activeData = useMemo(() => { return activeIndex !== null ? data[activeIndex] : data[1]; }, [activeIndex]); const totalVisitors = activeData.visitors; const totalRevenue = activeData.revenue; return ( {/* Header */}

Product page views

Last 7 days

{/* Chart */}
{ if (state?.activeTooltipIndex !== undefined) { setActiveIndex(state.activeTooltipIndex); } }} onMouseLeave={() => setActiveIndex(null)} > } cursor={false} /> {/* Revenue bars */} {data.map((entry, index) => ( ))}
{/* Metrics */}
{totalVisitors.toLocaleString()}
Visitors
${totalRevenue.toLocaleString()}
Revenue
); }