diff --git a/site/source/components/charts/PagesCharts.tsx b/site/source/components/charts/PagesCharts.tsx index c200aa1d3..f16a4043b 100644 --- a/site/source/components/charts/PagesCharts.tsx +++ b/site/source/components/charts/PagesCharts.tsx @@ -1,4 +1,6 @@ import { formatValue } from 'publicodes' +import { ComponentProps, ReactElement } from 'react' +import { useTranslation } from 'react-i18next' import { Bar, ComposedChart, @@ -43,6 +45,8 @@ function getColor(i: number): string { export default function PagesChart({ data, sync = true }: PagesChartProps) { const [darkMode] = useDarkMode() + const { t } = useTranslation() + if (!data.length) { return null } @@ -50,6 +54,10 @@ export default function PagesChart({ data, sync = true }: PagesChartProps) { const dataKeys = Object.keys(data[0].nombre) const flattenedData = (data as any).map((d: any) => ({ ...d, ...d.nombre })) + const ComposedChartWithRole = ( + props: ComponentProps | { role: string } + ): ReactElement => + return ( - ))} - + ) diff --git a/site/source/pages/statistiques/Chart.tsx b/site/source/pages/statistiques/Chart.tsx index bdff6ca0f..755ba5c72 100644 --- a/site/source/pages/statistiques/Chart.tsx +++ b/site/source/pages/statistiques/Chart.tsx @@ -1,5 +1,6 @@ import { formatValue } from 'publicodes' -import { ComponentProps, useContext } from 'react' +import { ComponentProps, ReactElement, ReactNode, useContext } from 'react' +import { useTranslation } from 'react-i18next' import { Area, Bar, @@ -72,6 +73,7 @@ export default function VisitsChart({ startIndex, endIndex, }: VisitsChartProps) { + const { t } = useTranslation() const [darkMode] = useDarkMode() const { colors } = useContext(ThemeContext) if (!data.length) { @@ -97,6 +99,10 @@ export default function VisitsChart({ return Palette[i % Palette.length] } + const ComposedChartWithRole = ( + props: ComponentProps | { role: string } + ): ReactElement => + return ( - {data.length > 1 && onDateChange && ( ) )} - + ) diff --git a/site/source/pages/statistiques/SatisfactionChart.tsx b/site/source/pages/statistiques/SatisfactionChart.tsx index 6ecffee16..5ef461fca 100644 --- a/site/source/pages/statistiques/SatisfactionChart.tsx +++ b/site/source/pages/statistiques/SatisfactionChart.tsx @@ -1,5 +1,5 @@ -import { ReactElement, useState } from 'react' -import { Trans } from 'react-i18next' +import { ComponentProps, ReactElement, useState } from 'react' +import { Trans, useTranslation } from 'react-i18next' import { Bar, BarChart, @@ -54,7 +54,7 @@ type DataType = 'nombres' | 'pourcentage' export default function SatisfactionChart({ data }: SatisfactionChartProps) { const [darkMode] = useDarkMode() const [dataType, setDataType] = useState('nombres') - + const { t } = useTranslation() if (!data.length) { return null } @@ -72,6 +72,10 @@ export default function SatisfactionChart({ data }: SatisfactionChartProps) { })) .filter((d) => Object.values(d.nombre).reduce((a, b) => a + b, 0)) + const BarChartWithRole = ( + props: ComponentProps | { role: string } + ): ReactElement => + return ( - + ))} - + )