From 410d6e09605aa2b1991d2e84bec38136c47b049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Tue, 26 Jul 2022 18:01:17 +0200 Subject: [PATCH] Hack to resize charts for googlebot --- site/source/components/charts/PagesCharts.tsx | 6 ++-- site/source/pages/Stats/Chart.tsx | 31 +++++++++++++++++-- site/source/pages/Stats/SatisfactionChart.tsx | 14 +++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/site/source/components/charts/PagesCharts.tsx b/site/source/components/charts/PagesCharts.tsx index 58ee84cb4b..c36fd9c62f 100644 --- a/site/source/components/charts/PagesCharts.tsx +++ b/site/source/components/charts/PagesCharts.tsx @@ -1,12 +1,12 @@ import { Strong } from '@/design-system/typography' import { Li, Ul } from '@/design-system/typography/list' import { Body } from '@/design-system/typography/paragraphs' +import { RealResponsiveContainer } from '@/pages/Stats/Chart' import { formatValue } from 'publicodes' import { Bar, ComposedChart, Legend, - ResponsiveContainer, Tooltip, TooltipProps, XAxis, @@ -49,7 +49,7 @@ export default function PagesChart({ data, sync = true }: PagesChartProps) { return ( - ))} - + ) } diff --git a/site/source/pages/Stats/Chart.tsx b/site/source/pages/Stats/Chart.tsx index 63cddd88e7..c5c10a6339 100644 --- a/site/source/pages/Stats/Chart.tsx +++ b/site/source/pages/Stats/Chart.tsx @@ -3,7 +3,7 @@ import { Strong } from '@/design-system/typography' import { Li, Ul } from '@/design-system/typography/list' import { Body } from '@/design-system/typography/paragraphs' import { formatValue } from 'publicodes' -import { useContext } from 'react' +import { ComponentProps, useContext } from 'react' import { Area, Bar, @@ -103,7 +103,7 @@ export default function VisitsChart({ } `} > - + - + ) } +export const RealResponsiveContainer = ( + props: ComponentProps +) => ( +
+
+ +
+
+) + function formatDay(date: string | Date) { return new Date(date).toLocaleString('default', { day: '2-digit', diff --git a/site/source/pages/Stats/SatisfactionChart.tsx b/site/source/pages/Stats/SatisfactionChart.tsx index f44c00a9a8..d9cf649799 100644 --- a/site/source/pages/Stats/SatisfactionChart.tsx +++ b/site/source/pages/Stats/SatisfactionChart.tsx @@ -3,14 +3,8 @@ import Emoji from '@/components/utils/Emoji' import { Strong } from '@/design-system/typography' import { Li, Ul } from '@/design-system/typography/list' import { Body } from '@/design-system/typography/paragraphs' -import { - Bar, - BarChart, - LabelList, - ResponsiveContainer, - Tooltip, - XAxis, -} from 'recharts' +import { Bar, BarChart, LabelList, Tooltip, XAxis } from 'recharts' +import { RealResponsiveContainer } from './Chart' import { SatisfactionLevel } from './types' export const SatisfactionStyle: [ @@ -51,7 +45,7 @@ export default function SatisfactionChart({ data }: SatisfactionChartProps) { return ( - + ))} - + ) }