Skip to content

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

fix: handle non-dates in chart header label (#21774)

Jordi Enricc394886d2444
diff --git a/apps/studio/components/ui/Charts/BarChart.tsx b/apps/studio/components/ui/Charts/BarChart.tsx
index 2e45ba94213..a8cce3d7fb0 100644
--- a/apps/studio/components/ui/Charts/BarChart.tsx
+++ b/apps/studio/components/ui/Charts/BarChart.tsx
@@ -47,12 +47,22 @@ const BarChart = ({
return <ChartNoData message={emptyStateMessage} size={size} className={className} />
const day = (value: number | string) => (displayDateInUtc ? dayjs(value).utc() : dayjs(value))
- const resolvedHighlightedLabel =
- (focusDataIndex !== null &&
- data &&
- data[focusDataIndex] !== undefined &&
- day(data[focusDataIndex][xAxisKey]).format(customDateFormat)) ||
- highlightedLabel
+
+ function getHeaderLabel() {
+ if (!xAxisIsDate) {
+ if (!focusDataIndex) return highlightedLabel
+ return data[focusDataIndex]?.[xAxisKey]
+ }
+ return (
+ (focusDataIndex !== null &&
+ data &&
+ data[focusDataIndex] !== undefined &&
+ day(data[focusDataIndex][xAxisKey]).format(customDateFormat)) ||
+ highlightedLabel
+ )
+ }
+
+ const resolvedHighlightedLabel = getHeaderLabel()
const resolvedHighlightedValue =
focusDataIndex !== null ? data[focusDataIndex]?.[yAxisKey] : highlightedValue