feat(dashboard): add recharts data visualizations
- Install recharts - Add WatchActivityChart (AreaChart, movies + episodes/month, year filter) - Add WatchTimeChart (stacked BarChart, hours/month, synced year filter) - Add RatingsChart (BarChart, user ratings distribution 1–10, color ramp) - Add TopGenresChart (horizontal BarChart, top 10 genres, type filter) - Add CouchDayChart (BarChart, watch count by weekday, peak day highlight) - Add GET /statistics/watch-weekday backend endpoint (DAYOFWEEK aggregation) - Extend statisticsApi with getYearlyWatchCount, getYearlyWatchTime, getWatchdayDistribution - Add useYearlyWatchCount, useYearlyWatchTime, useWatchdayDistribution hooks - Wire all charts into DashboardPage with responsive two-column grid layout
This commit is contained in:
1 parent
3648c41cfd
commit
ae67663623
12 files changed
+1216
-2
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useStatistics } from '@/hooks/useStatistics';
|
||||
@@ -7,11 +7,17 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Film, Tv, Heart, ListVideo, Clock } from 'lucide-react';
|
||||
import { formatRuntime, getPosterUrl } from '@/lib/media-utils';
|
||||
import { WatchActivityChart } from '@/components/dashboard/WatchActivityChart';
|
||||
import { WatchTimeChart } from '@/components/dashboard/WatchTimeChart';
|
||||
import { RatingsChart } from '@/components/dashboard/RatingsChart';
|
||||
import { TopGenresChart } from '@/components/dashboard/TopGenresChart';
|
||||
import { CouchDayChart } from '@/components/dashboard/CouchDayChart';
|
||||
|
||||
export function DashboardPage() {
|
||||
useLibrary();
|
||||
const { data: stats, isLoading: statsLoading } = useStatistics();
|
||||
const allEntries = useLibraryEntries();
|
||||
const [watchYear, setWatchYear] = useState(new Date().getFullYear());
|
||||
|
||||
const movies = useMemo(() => allEntries.filter((e) => !e.is_tvseries && !e.watchlist), [allEntries]);
|
||||
const tvSeries = useMemo(() => allEntries.filter((e) => e.is_tvseries && !e.watchlist), [allEntries]);
|
||||
@@ -78,6 +84,15 @@ export function DashboardPage() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Charts */}
|
||||
<WatchActivityChart />
|
||||
<WatchTimeChart year={watchYear} onYearChange={setWatchYear} />
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<RatingsChart />
|
||||
<TopGenresChart />
|
||||
</div>
|
||||
<CouchDayChart />
|
||||
|
||||
{/* Recently Watched */}
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-lg font-semibold">Recently Watched</h2>
|
||||
@@ -99,7 +114,7 @@ export function DashboardPage() {
|
||||
<img
|
||||
src={getPosterUrl(entry)}
|
||||
alt={entry.title}
|
||||
className="aspect-[2/3] w-full rounded-lg object-cover"
|
||||
className="aspect-2/3 w-full rounded-lg object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
<p className="mt-1 text-xs font-medium truncate">
|
||||
|
||||
Reference in new issue
Block a user