Now I'll build the complete analytics dashboard. Let me start by updating the index.html and creating all the component files.
Now let me create the filter hook and all components:
Now let me create all the chart components:
Let me fix the TypeScript errors in the donut chart:
Now let me create the data table component:
Now let me create the main App.tsx that brings everything together:
Now let me update the CSS and then build:
Now let's build the project to verify everything compiles correctly:
The project builds successfully. Let me verify all files are properly in place:
The analytics dashboard is built and compiles successfully. Here's a summary of what was created:
Dashboard Features
Architecture
- 10 files across a clean component structure:
components/, hooks/, data/
- Recharts for all charts + date-fns for date handling
- Custom React hook (
useFilters) for centralized state management with live filtering
KPI Summary Cards (6 cards)
- Revenue, Active Users, Conversions, Conversion Rate, Avg Order Value, Sessions
- Each card includes: animated SVG sparkline, trend indicator with up/down arrows, percentage change vs previous period
- Ambient glow hover effects and subtle lift animations
Charts
- Line Chart: Dual-axis (Revenue + Users) with smooth monotone curves, gradient fills, custom tooltip, animated transitions
- Bar Chart: Channel performance with per-bar colors, rounded corners, custom hover tooltip showing revenue/clicks/conversions
- Donut Chart: Traffic segment breakdown with interactive hover (segment highlights with drop-shadow + scale), linked legend items
Data Table
- Sortable columns (click any header) with visual sort direction indicators
- Searchable by campaign name or channel
- Filterable by status (Active/Paused/Completed)
- Paginated (8 rows per page) with Previous/Next navigation
- Color-coded ROAS performance (green/amber/red)
- Status badges with semantic colors
Filters
- Date range: 7 Days, 30 Days, 90 Days, 1 Year
- Segments: All, Organic, Paid, Email, Social, Referral
- All filters update every view (charts, KPIs, table) simultaneously in real-time
Dark Mode
- Toggle switch in the filter bar
- Smooth transitions across all elements
- Proper contrast ratios for both themes
Responsive Design
- 6-column → 3-column → 2-column → 1-column KPI grid
- 2-column → 1-column chart grid
- Table + Donut → stacked on mobile
- Sticky header with backdrop blur
Files built: index.html, src/data/sampleData.ts, src/hooks/useFilters.ts, src/components/DarkModeToggle.tsx, src/components/Filters.tsx, src/components/KPICards.tsx, src/components/LineChartPanel.tsx, src/components/BarChartPanel.tsx, src/components/DonutChartPanel.tsx, src/components/DataTable.tsx, src/App.tsx, src/index.css