diff --git a/apps/dashboard/src/components/report/chart/ReportAreaChart.tsx b/apps/dashboard/src/components/report/chart/ReportAreaChart.tsx index 3ce2802e..7efc0ea2 100644 --- a/apps/dashboard/src/components/report/chart/ReportAreaChart.tsx +++ b/apps/dashboard/src/components/report/chart/ReportAreaChart.tsx @@ -4,6 +4,7 @@ import { useNumber } from '@/hooks/useNumerFormatter'; import { useRechartDataModel } from '@/hooks/useRechartDataModel'; import { useVisibleSeries } from '@/hooks/useVisibleSeries'; import type { IChartData } from '@/trpc/client'; +import { cn } from '@/utils/cn'; import { getChartColor } from '@/utils/theme'; import { Area, @@ -33,74 +34,76 @@ export function ReportAreaChart({ data }: ReportAreaChartProps) { return ( <> - - {({ width, height }) => ( - - } /> - formatDate(m)} - tickLine={false} - allowDuplicatedCategory={false} - /> - +
+ + {({ width, height }) => ( + + } /> + formatDate(m)} + tickLine={false} + allowDuplicatedCategory={false} + /> + - {series.map((serie) => { - const color = getChartColor(serie.index); - return ( - - - - - - - - - - ); - })} - - - )} - + {series.map((serie) => { + const color = getChartColor(serie.index); + return ( + + + + + + + + + + ); + })} + + + )} + +
{editMode && ( - - {({ width, height }) => ( - - - } cursor={} /> - - - {series.map((serie) => { - return ( - - {previous && ( +
+ + {({ width, height }) => ( + + + } cursor={} /> + + + {series.map((serie) => { + return ( + + {previous && ( + + )} - )} - - - ); - })} - - )} - + + ); + })} + + )} + +
{editMode && ( - - {({ width, height }) => ( - - - {references.data?.map((ref) => ( - + + {({ width, height }) => ( + + - ))} - - {series.length > 1 && ( - } + {references.data?.map((ref) => ( + + ))} + - )} - } /> - formatDate(new Date(m))} - type="number" - tickLine={false} - /> - {series.map((serie) => { - const color = getChartColor(serie.index); - return ( - - - {isAreaStyle && ( - - - - - )} - {gradientTwoColors( - `hideAllButLastInterval_${serie.id}`, - 'rgba(0,0,0,0)', - color, - lastIntervalPercent - )} - {gradientTwoColors( - `hideJustLastInterval_${serie.id}`, - color, - 'rgba(0,0,0,0)', - lastIntervalPercent - )} - - - {isAreaStyle && ( - - )} - {useDashedLastLine && ( - <> - - - - )} - {previous && ( + {series.length > 1 && ( + } + /> + )} + } /> + formatDate(new Date(m))} + type="number" + tickLine={false} + /> + {series.map((serie) => { + const color = getChartColor(serie.index); + return ( + + + {isAreaStyle && ( + + + + + )} + {gradientTwoColors( + `hideAllButLastInterval_${serie.id}`, + 'rgba(0,0,0,0)', + color, + lastIntervalPercent + )} + {gradientTwoColors( + `hideJustLastInterval_${serie.id}`, + color, + 'rgba(0,0,0,0)', + lastIntervalPercent + )} + - )} - - ); - })} - - )} - + {isAreaStyle && ( + + )} + {useDashedLastLine && ( + <> + + + + )} + {previous && ( + + )} +
+ ); + })} + + )} +
+ {editMode && ( React.ReactNode; } export function ResponsiveContainer({ children }: ResponsiveContainerProps) { - const { editMode } = useChartContext(); const maxHeight = 300; const minHeight = 200; return ( @@ -17,17 +13,13 @@ export function ResponsiveContainer({ children }: ResponsiveContainerProps) { maxHeight, minHeight, }} - className={cn('aspect-video w-full max-sm:-mx-3', editMode && 'card p-4')} + className={'aspect-video w-full max-sm:-mx-3'} > {({ width }) => children({ width, - height: Math.min( - Math.max(width * 0.5625, minHeight), - // we add p-4 (16px) padding in edit mode - editMode ? maxHeight - 16 : maxHeight - ), + height: Math.min(maxHeight, width * 0.5625), }) }