A modern, responsive analytics dashboard built with React, TypeScript, and Chart.js. Features real-time data visualization, interactive charts, and a clean, professional UI.
- Interactive data visualizations with Chart.js
- Real-time data updates
- Responsive design for all devices
- Multiple chart types (Line, Bar, Pie, Doughnut)
- Advanced filtering and date range selection
- Export data to CSV/PDF
- Dark mode support
- TypeScript for type safety
- REST API integration
- Performance optimized with React hooks
- Framework: React 18 with TypeScript
- Charts: Chart.js & React-Chartjs-2
- Styling: Tailwind CSS
- State Management: React Context API
- HTTP Client: Axios
- Date Handling: date-fns
- Icons: React Icons
- Build Tool: Vite
- Node.js >= 16.x
- npm or yarn
# Clone the repository
git clone https://github.com/simonbrizuela/analytics-dashboard-react.git
cd analytics-dashboard-react
# Install dependencies
npm install
# Start development server
npm run devCreate a .env file in the root directory:
VITE_API_URL=http://localhost:3000/api
VITE_APP_TITLE=Analytics Dashboard
VITE_ENABLE_MOCK_DATA=truenpm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm run type-check # TypeScript type checkinganalytics-dashboard-react/
├── src/
│ ├── components/
│ │ ├── charts/
│ │ │ ├── LineChart.tsx
│ │ │ ├── BarChart.tsx
│ │ │ ├── PieChart.tsx
│ │ │ └── DoughnutChart.tsx
│ │ ├── dashboard/
│ │ │ ├── Dashboard.tsx
│ │ │ ├── StatCard.tsx
│ │ │ └── DateRangePicker.tsx
│ │ ├── layout/
│ │ │ ├── Header.tsx
│ │ │ ├── Sidebar.tsx
│ │ │ └── Footer.tsx
│ │ └── common/
│ │ ├── Button.tsx
│ │ ├── Card.tsx
│ │ └── Loading.tsx
│ ├── context/
│ │ ├── ThemeContext.tsx
│ │ └── DataContext.tsx
│ ├── services/
│ │ ├── api.ts
│ │ └── mockData.ts
│ ├── types/
│ │ └── index.ts
│ ├── utils/
│ │ ├── formatters.ts
│ │ ├── exportData.ts
│ │ └── constants.ts
│ ├── hooks/
│ │ ├── useAnalytics.ts
│ │ └── useTheme.ts
│ ├── App.tsx
│ └── main.tsx
├── public/
├── index.html
├── package.json
├── tsconfig.json
├── vite.config.ts
└── tailwind.config.js
- Total Revenue
- Active Users
- Conversion Rate
- Average Order Value
- Sales trends over time
- User growth analytics
- Geographic distribution
- Line Chart - Revenue and sales trends
- Bar Chart - Monthly comparisons
- Pie Chart - Category distribution
- Doughnut Chart - User segments
- Date range selection (Last 7 days, 30 days, 90 days, Custom)
- Category filtering
- Status filtering
- Search functionality
The dashboard connects to a REST API for data:
// Example API endpoints
GET /api/analytics/overview
GET /api/analytics/revenue?startDate=2024-01-01&endDate=2024-12-31
GET /api/analytics/users
GET /api/analytics/conversionsimport { Dashboard } from './components/dashboard/Dashboard';
import { ThemeProvider } from './context/ThemeContext';
function App() {
return (
<ThemeProvider>
<Dashboard />
</ThemeProvider>
);
}Edit tailwind.config.js to customize colors:
module.exports = {
theme: {
extend: {
colors: {
primary: '#3b82f6',
secondary: '#8b5cf6',
success: '#10b981',
warning: '#f59e0b',
danger: '#ef4444'
}
}
}
}Customize chart options in src/utils/constants.ts:
export const chartOptions = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top'
}
}
};- Code splitting with React.lazy
- Memoization with useMemo and useCallback
- Virtualization for large datasets
- Debounced search and filters
- Optimized re-renders
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
The dashboard includes:
- Clean, professional interface
- Responsive grid layout
- Interactive hover effects
- Smooth animations
- Accessible color schemes
MIT License
Simon Brizuela
- GitHub: @simonbrizuela
- Email: simonbrizuela08@gmail.com
Pull requests are welcome. For major changes, please open an issue first.