Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix missing x axis labels in reports (#37378)

Joshen Lima26f96570ec8
diff --git a/apps/studio/components/ui/Charts/ComposedChart.tsx b/apps/studio/components/ui/Charts/ComposedChart.tsx
index 3dd9ae6aa3b..78e1e45a09c 100644
--- a/apps/studio/components/ui/Charts/ComposedChart.tsx
+++ b/apps/studio/components/ui/Charts/ComposedChart.tsx
@@ -1,12 +1,14 @@
'use client'
import dayjs from 'dayjs'
+import { formatBytes } from 'lib/helpers'
import { useTheme } from 'next-themes'
import { ComponentProps, useEffect, useState } from 'react'
import {
Area,
Bar,
CartesianGrid,
+ Label,
Line,
ComposedChart as RechartComposedChart,
ReferenceArea,
@@ -14,7 +16,6 @@ import {
Tooltip,
XAxis,
YAxis,
- Label,
} from 'recharts'
import { CategoricalChartState } from 'recharts/types/chart/types'
import { cn } from 'ui'
@@ -28,11 +29,14 @@ import {
} from './Charts.constants'
import { CommonChartProps, Datum } from './Charts.types'
import { numberFormatter, useChartSize } from './Charts.utils'
-import { calculateTotalChartAggregate, CustomLabel, CustomTooltip } from './ComposedChart.utils'
+import {
+ calculateTotalChartAggregate,
+ CustomLabel,
+ CustomTooltip,
+ MultiAttribute,
+} from './ComposedChart.utils'
import NoDataPlaceholder from './NoDataPlaceholder'
-import { MultiAttribute } from './ComposedChart.utils'
import { ChartHighlight } from './useChartHighlight'
-import { formatBytes } from 'lib/helpers'
export interface ComposedChartProps<D = Datum> extends CommonChartProps<D> {
attributes: MultiAttribute[]
diff --git a/apps/studio/components/ui/Charts/ComposedChartHandler.tsx b/apps/studio/components/ui/Charts/ComposedChartHandler.tsx
index 25ab41228eb..400a7a40afc 100644
--- a/apps/studio/components/ui/Charts/ComposedChartHandler.tsx
+++ b/apps/studio/components/ui/Charts/ComposedChartHandler.tsx
@@ -1,21 +1,22 @@
-import React, { PropsWithChildren, useState, useMemo, useEffect, useRef } from 'react'
-import { useRouter } from 'next/router'
import { Loader2 } from 'lucide-react'
+import { useRouter } from 'next/router'
+import React, { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react'
import { cn, WarningIcon } from 'ui'
import Panel from 'components/ui/Panel'
import ComposedChart from './ComposedChart'
import { AnalyticsInterval, DataPoint } from 'data/analytics/constants'
-import { InfraMonitoringAttribute } from 'data/analytics/infra-monitoring-query'
import { useInfraMonitoringQueries } from 'data/analytics/infra-monitoring-queries'
-import { ProjectDailyStatsAttribute } from 'data/analytics/project-daily-stats-query'
+import { InfraMonitoringAttribute } from 'data/analytics/infra-monitoring-query'
import { useProjectDailyStatsQueries } from 'data/analytics/project-daily-stats-queries'
+import { ProjectDailyStatsAttribute } from 'data/analytics/project-daily-stats-query'
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import { useChartHighlight } from './useChartHighlight'
-import type { ChartData } from './Charts.types'
+import dayjs from 'dayjs'
import type { UpdateDateRange } from 'pages/project/[ref]/reports/database'
+import type { ChartData } from './Charts.types'
import { MultiAttribute } from './ComposedChart.utils'
export interface ComposedChartHandlerProps {
@@ -199,7 +200,12 @@ const ComposedChartHandler = ({
point[attr] = value
})
- return point as DataPoint
+ const formattedDataPoint: DataPoint =
+ !('period_start' in point) && 'timestamp' in point
+ ? { ...point, period_start: dayjs.utc(point.timestamp).unix() * 1000 }
+ : point
+
+ return formattedDataPoint
})
return combined as DataPoint[]
@@ -275,6 +281,7 @@ const ComposedChartHandler = ({
attributes={attributes}
data={combinedData as DataPoint[]}
format={format}
+ // [Joshen] This is where it's messing up
xAxisKey="period_start"
yAxisKey={attributes[0].attribute}
highlightedValue={_highlightedValue}