diff --git a/frontend/src/context/useChartTheme.ts b/frontend/src/context/useChartTheme.ts
new file mode 100644
index 0000000..c93142c
--- /dev/null
+++ b/frontend/src/context/useChartTheme.ts
@@ -0,0 +1,41 @@
+import { useTheme } from './ThemeContext';
+
+/**
+ * Returns theme-aware color values for recharts components.
+ *
+ * Recharts accepts only raw color strings (not CSS variables),
+ * so this hook bridges the Tailwind/CSS-variable theme system
+ * to the imperative recharts API.
+ */
+export function useChartTheme() {
+ const { theme } = useTheme();
+ const isDark = theme === 'dark';
+
+ return {
+ /** Axis tick and grid line stroke color */
+ axisStroke: isDark ? '#94a3b8' : '#64748b',
+ /** Tooltip container background */
+ tooltipBg: isDark ? '#1e293b' : '#ffffff',
+ /** Tooltip container border */
+ tooltipBorder: isDark
+ ? '1px solid rgba(99, 102, 241, 0.3)'
+ : '1px solid rgba(99, 102, 241, 0.2)',
+ /** Tooltip label text color */
+ tooltipLabelColor: isDark ? '#f8fafc' : '#0f172a',
+ /** Tooltip item text color */
+ tooltipItemColor: isDark ? '#e2e8f0' : '#334155',
+ /** Convenience: full contentStyle object for recharts Tooltip */
+ tooltipContentStyle: {
+ backgroundColor: isDark ? '#1e293b' : '#ffffff',
+ border: isDark
+ ? '1px solid rgba(99, 102, 241, 0.3)'
+ : '1px solid rgba(99, 102, 241, 0.2)',
+ borderRadius: '8px',
+ color: isDark ? '#f8fafc' : '#0f172a',
+ },
+ /** Convenience: labelStyle for recharts Tooltip */
+ tooltipLabelStyle: {
+ color: isDark ? '#f8fafc' : '#0f172a',
+ },
+ };
+}
diff --git a/frontend/src/pages/Analytics.tsx b/frontend/src/pages/Analytics.tsx
index 194cf9f..b7c4604 100644
--- a/frontend/src/pages/Analytics.tsx
+++ b/frontend/src/pages/Analytics.tsx
@@ -3,11 +3,13 @@ import { useQuery } from '@tanstack/react-query';
import { analyticsApi } from '../api/client';
import { AlertCircle, Database } from 'lucide-react';
import { PieChart, Pie, Cell, BarChart, Bar, LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, Legend } from 'recharts';
+import { useChartTheme } from '../context/useChartTheme';
const COLORS = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#14b8a6'];
export function AnalyticsPage() {
const [days, setDays] = useState(30);
+ const chartTheme = useChartTheme();
const { data, isLoading, isError, refetch } = useQuery({
queryKey: ['analytics', days],
@@ -160,11 +162,7 @@ export function AnalyticsPage() {
))}