Changed around line 1
+ // Theme toggling
+ const themeToggle = document.querySelector('.theme-toggle');
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
+
+ function setTheme(isDark) {
+ document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light');
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
+ }
+
+ themeToggle.addEventListener('click', () => {
+ const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
+ setTheme(!isDark);
+ });
+
+ // Initialize theme
+ const savedTheme = localStorage.getItem('theme');
+ if (savedTheme) {
+ setTheme(savedTheme === 'dark');
+ } else {
+ setTheme(prefersDark.matches);
+ }
+
+ // Charts initialization (using canvas 2D context for simplicity)
+ function initializeCharts() {
+ const revenueCtx = document.getElementById('revenueChart').getContext('2d');
+ const usersCtx = document.getElementById('usersChart').getContext('2d');
+
+ // Simple line drawing for demonstration
+ function drawLine(ctx, points, color) {
+ ctx.beginPath();
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 2;
+ points.forEach((point, index) => {
+ if (index === 0) {
+ ctx.moveTo(point.x, point.y);
+ } else {
+ ctx.lineTo(point.x, point.y);
+ }
+ });
+ ctx.stroke();
+ }
+
+ // Generate random data points
+ const revenueData = Array.from({length: 12}, (_, i) => ({
+ x: i * 30,
+ y: 100 + Math.random() * 100
+ }));
+
+ const userData = Array.from({length: 12}, (_, i) => ({
+ x: i * 30,
+ y: 100 + Math.random() * 100
+ }));
+
+ drawLine(revenueCtx, revenueData, '#6366f1');
+ drawLine(usersCtx, userData, '#4f46e5');
+ }
+
+ // Recent activity data
+ const activityData = [
+ { action: 'New order received', time: '2 minutes ago' },
+ { action: 'User registration', time: '15 minutes ago' },
+ { action: 'Payment processed', time: '1 hour ago' },
+ { action: 'Inventory updated', time: '2 hours ago' },
+ ];
+
+ function populateActivity() {
+ const activityList = document.querySelector('.activity-list');
+ activityData.forEach(item => {
+ const div = document.createElement('div');
+ div.className = 'activity-item';
+ div.innerHTML = `
+ ${item.time}
+ `;
+ activityList.appendChild(div);
+ });
+ }
+
+ // Initialize everything when DOM is loaded
+ document.addEventListener('DOMContentLoaded', () => {
+ initializeCharts();
+ populateActivity();
+ });