diff --git a/public/i18n/de.json b/public/i18n/de.json index 899be1b..e69a44e 100644 --- a/public/i18n/de.json +++ b/public/i18n/de.json @@ -560,6 +560,16 @@ "TURN_BASED_STRATEGY_TBS": "Rundenstrategie", "VISUAL_NOVEL": "Visual Novel" }, + "CHART": { + "LABEL": "Diagramm", + "BARS": "Balken", + "PIE": "Torte", + "DONUT": "Ring", + "LINE": "Linie", + "LIST": "Liste", + "OTHER": "Andere", + "OVERLAP": "Anteil der Spiele, ein Spiel kann mehrfach zählen" + }, "DRILL": { "SHOW_ALL": "Alle anzeigen", "LOAD_MORE": "Mehr laden", diff --git a/public/i18n/en.json b/public/i18n/en.json index 634686a..0b4ce0a 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -560,6 +560,16 @@ "TURN_BASED_STRATEGY_TBS": "Turn-based strategy", "VISUAL_NOVEL": "Visual novel" }, + "CHART": { + "LABEL": "Chart", + "BARS": "Bars", + "PIE": "Pie", + "DONUT": "Donut", + "LINE": "Line", + "LIST": "List", + "OTHER": "Other", + "OVERLAP": "Share of games, a game can count more than once" + }, "DRILL": { "SHOW_ALL": "Show all", "LOAD_MORE": "Load more", diff --git a/src/components/stats/ChartPicker.jsx b/src/components/stats/ChartPicker.jsx new file mode 100644 index 0000000..ed55bc4 --- /dev/null +++ b/src/components/stats/ChartPicker.jsx @@ -0,0 +1,25 @@ +import {useTranslation} from 'react-i18next'; + +import {Button} from '@/components/ui/button'; +import {STAT_CHARTS} from '../../utils/statCharts.js'; + +/** + * The chart forms of a stat group as buttons. + * + * @param value the shown form + * @param onChange `(form)` + */ +export default function ChartPicker({group, value, onChange}) { + const {t} = useTranslation(); + return ( +
+ {STAT_CHARTS[group].map((form) => ( + + ))} +
+ ); +} diff --git a/src/components/stats/FinishedStats.jsx b/src/components/stats/FinishedStats.jsx index f75e11b..9969f8f 100644 --- a/src/components/stats/FinishedStats.jsx +++ b/src/components/stats/FinishedStats.jsx @@ -2,12 +2,15 @@ import {useTranslation} from 'react-i18next'; import {Flag} from 'lucide-react'; import StatsSection from './StatsSection.jsx'; +import ChartPicker from './ChartPicker.jsx'; +import YearLine from './YearLine.jsx'; import {DrillRow, StatCount, useStatDrill} from './StatDrill.jsx'; /** * @param onSelect `(year)`: the rows are buttons + * @param bars false: a plain list, without the bars */ -export function YearBars({perYear, onSelect}) { +export function YearBars({perYear, onSelect, bars = true}) { const max = Math.max(1, ...perYear.map((y) => y.games)); return (