refactor(webui): drop deprecated recharts cell usage

- replace Cell-based pie slice coloring with data-driven fill props
- keep the stats genre and database charts visually unchanged
- remove the deprecation warning from the stats route
This commit is contained in:
Antti Kettunen 2026-05-14 17:46:52 +03:00
parent 23de70958a
commit c9ba5e36a4
No known key found for this signature in database
GPG key ID: C6B2A3D250359BD7

View file

@ -5,7 +5,6 @@ import {
Bar,
BarChart,
CartesianGrid,
Cell,
Pie,
PieChart,
ResponsiveContainer,
@ -347,7 +346,10 @@ function StatsGenreChart({
}: {
genres: Array<{ genre: string; play_count: number; percentage: number }>;
}) {
const topGenres = genres.slice(0, 10);
const topGenres = genres.slice(0, 10).map((genre, index) => ({
...genre,
fill: STATS_GENRE_COLORS[index % STATS_GENRE_COLORS.length],
}));
return (
<ResponsiveContainer width={180} height={180}>
<PieChart>
@ -359,11 +361,7 @@ function StatsGenreChart({
outerRadius={84}
paddingAngle={2}
stroke="transparent"
>
{topGenres.map((genre, index) => (
<Cell key={genre.genre} fill={STATS_GENRE_COLORS[index % STATS_GENRE_COLORS.length]} />
))}
</Pie>
/>
<Tooltip contentStyle={STATS_TOOLTIP_STYLE} wrapperStyle={STATS_TOOLTIP_WRAPPER_STYLE} />
</PieChart>
</ResponsiveContainer>
@ -782,7 +780,10 @@ function StatsDbStorage({
return <SectionSubtleError message={getErrorMessage(error)} />;
}
const tables = groupDbStorageTables(payload?.tables ?? []);
const tables = groupDbStorageTables(payload?.tables ?? []).map((table, index) => ({
...table,
fill: STATS_DB_STORAGE_COLORS[index % STATS_DB_STORAGE_COLORS.length],
}));
const method = payload?.method;
return (
@ -798,14 +799,7 @@ function StatsDbStorage({
outerRadius={84}
paddingAngle={2}
stroke="transparent"
>
{tables.map((table, index) => (
<Cell
key={table.name}
fill={STATS_DB_STORAGE_COLORS[index % STATS_DB_STORAGE_COLORS.length]}
/>
))}
</Pie>
/>
<Tooltip
contentStyle={STATS_TOOLTIP_STYLE}
wrapperStyle={STATS_TOOLTIP_WRAPPER_STYLE}