Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

feat(frontend): restore the tracked category charts with Intent UI

spacesdrivec22d7c531a43
diff --git a/frontend/src/features/analytics/tracked/CategoryRedditSection.tsx b/frontend/src/features/analytics/tracked/CategoryRedditSection.tsx
index c40bf52..7eb6eaa 100644
--- a/frontend/src/features/analytics/tracked/CategoryRedditSection.tsx
+++ b/frontend/src/features/analytics/tracked/CategoryRedditSection.tsx
@@ -3,7 +3,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
import MetricBox from '@/components/MetricBox';
import SurfaceBox from '@/components/SurfaceBox';
import SectionHeader from '@/components/SectionHeader';
-import RankingBarChart from '@/components/RankingBarChart';
+import MetricAreaChart from '@/components/MetricAreaChart';
import RelativeTime from '@/components/RelativeTime';
import Num from '@/components/Num';
import { METRIC_ICONS } from '@/lib/metricIcons';
@@ -12,7 +12,8 @@ import ColumnHint from '@/components/ColumnHint';
import { RankNumber } from '@/components/ListRow';
import { PlatformIcon } from '@/components/platform';
import { PLATFORM_META } from '@/lib/accounts';
-import { fmtNum } from '../../../utils/formatters';
+import { pointsOf, rankingSummary } from '@/lib/chart';
+import { fmtNum, fmtNumFull } from '../../../utils/formatters';
import { hasTrackedViews, trackedViews } from '../../../utils/trackedContent';
import NumberCell from './NumberCell';
import OpenLink from './OpenLink';
@@ -75,7 +76,15 @@ export default function CategoryRedditSection({ items, stats }: CategoryRedditSe
</div>
{chartData.length > 1 && (
<SurfaceBox title="Post karma" headingLevel="h3" subheader={`Top ${chartData.length} posts in this category ranked by karma`}>
- <RankingBarChart rows={chartData.map(point => ({ name: point.name, value: Number(point.karma) || 0 }))} label="Karma" title="Karma by post" color={PLATFORM_META.reddit.series} />
+ <MetricAreaChart
+ data={chartData}
+ dataKey="karma"
+ label="Karma"
+ title="Post karma"
+ description={rankingSummary(pointsOf(chartData, 'name', 'karma'), fmtNumFull, 'karma')}
+ color={PLATFORM_META.reddit.series}
+ height={260}
+ />
</SurfaceBox>
)}
<SurfaceBox title="All posts in this category" headingLevel="h3" content={false} className="overflow-hidden">
diff --git a/frontend/src/features/analytics/tracked/CategoryYouTubeSection.tsx b/frontend/src/features/analytics/tracked/CategoryYouTubeSection.tsx
index e9d5470..d270a8c 100644
--- a/frontend/src/features/analytics/tracked/CategoryYouTubeSection.tsx
+++ b/frontend/src/features/analytics/tracked/CategoryYouTubeSection.tsx
@@ -5,14 +5,15 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
import MetricBox from '@/components/MetricBox';
import SurfaceBox from '@/components/SurfaceBox';
import SectionHeader from '@/components/SectionHeader';
-import RankingBarChart from '@/components/RankingBarChart';
+import MetricAreaChart from '@/components/MetricAreaChart';
import RelativeTime from '@/components/RelativeTime';
import Num from '@/components/Num';
import { METRIC_ICONS } from '@/lib/metricIcons';
import { RankNumber } from '@/components/ListRow';
import { PlatformIcon } from '@/components/platform';
import { PLATFORM_META } from '@/lib/accounts';
-import { fmtNum } from '../../../utils/formatters';
+import { pointsOf, rankingSummary } from '@/lib/chart';
+import { fmtNum, fmtNumFull } from '../../../utils/formatters';
import NumberCell from './NumberCell';
import OpenLink from './OpenLink';
import { chartDataOf, sortedByViews } from './trackedCategoryStats.ts';
@@ -77,7 +78,15 @@ export default function CategoryYouTubeSection({ items, stats }: CategoryYouTube
</div>
{chartData.length > 1 && (
<SurfaceBox title="Video views" headingLevel="h3" subheader={`Top ${chartData.length} videos in this category ranked by views`}>
- <RankingBarChart rows={chartData.map(point => ({ name: point.name, value: Number(point.views) || 0 }))} label="Views" title="Views by video" color={PLATFORM_META.youtube.series} />
+ <MetricAreaChart
+ data={chartData}
+ dataKey="views"
+ label="Views"
+ title="Video views"
+ description={rankingSummary(pointsOf(chartData, 'name', 'views'), fmtNumFull, 'views')}
+ color={PLATFORM_META.youtube.series}
+ height={260}
+ />
</SurfaceBox>
)}
<SurfaceBox title="All videos in this category" headingLevel="h3" content={false} className="overflow-hidden">