Skip to content

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

Chore/db report legend (#35871)

Francesco Sansalvadore01503ea083b8
diff --git a/apps/studio/components/ui/Charts/ComposedChart.tsx b/apps/studio/components/ui/Charts/ComposedChart.tsx
index 5a94ec5367a..8a57a190b78 100644
--- a/apps/studio/components/ui/Charts/ComposedChart.tsx
+++ b/apps/studio/components/ui/Charts/ComposedChart.tsx
@@ -156,19 +156,23 @@ export default function ComposedChart({
const referenceLines = attributes.filter((attribute) => attribute?.provider === 'reference-line')
const resolvedHighlightedLabel = getHeaderLabel()
+
+ const attributesToIgnore =
+ attributes?.filter((a) => a.omitFromTotal)?.map((a) => a.attribute) ?? []
+
+ const attributesToIgnoreFromTotal = [
+ ...attributesToIgnore,
+ ...(referenceLines?.map((a: MultiAttribute) => a.attribute) ?? []),
+ ...(maxAttribute?.attribute ? [maxAttribute?.attribute] : []),
+ ]
+
const resolvedHighlightedValue =
focusDataIndex !== null
? showTotal
- ? calculateTotalChartAggregate(
- _activePayload,
- maxAttribute?.attribute ? referenceLines.map((a) => a.attribute) : []
- )
+ ? calculateTotalChartAggregate(_activePayload, attributesToIgnoreFromTotal)
: data[focusDataIndex]?.[yAxisKey]
: showTotal && lastDataPoint
- ? calculateTotalChartAggregate(
- lastDataPoint,
- maxAttribute?.attribute ? referenceLines.map((a) => a.attribute) : []
- )
+ ? calculateTotalChartAggregate(lastDataPoint, attributesToIgnoreFromTotal)
: highlightedValue
const showHighlightActions =
diff --git a/apps/studio/components/ui/Charts/ComposedChart.utils.tsx b/apps/studio/components/ui/Charts/ComposedChart.utils.tsx
index b7325c94061..16578ee99da 100644
--- a/apps/studio/components/ui/Charts/ComposedChart.utils.tsx
+++ b/apps/studio/components/ui/Charts/ComposedChart.utils.tsx
@@ -84,12 +84,20 @@ const CustomTooltip = ({
const isNetworkChart = payload?.some((p: any) => p.dataKey.toLowerCase().includes('network_'))
const shouldFormatBytes = isRamChart || isDiskSpaceChart || isDBSizeChart || isNetworkChart
- const total =
- showTotal &&
- calculateTotalChartAggregate(
- payload,
- maxValueAttribute?.attribute ? [maxValueAttribute.attribute] : []
- )
+ const attributesToIgnore =
+ attributes?.filter((a) => a.omitFromTotal)?.map((a) => a.attribute) ?? []
+ const referenceLines =
+ attributes
+ ?.filter((attribute: MultiAttribute) => attribute?.provider === 'reference-line')
+ ?.map((a: MultiAttribute) => a.attribute) ?? []
+
+ const attributesToIgnoreFromTotal = [
+ ...attributesToIgnore,
+ ...referenceLines,
+ ...(maxValueAttribute?.attribute ? [maxValueAttribute.attribute] : []),
+ ]
+
+ const total = showTotal && calculateTotalChartAggregate(payload, attributesToIgnoreFromTotal)
const getIcon = (color: string, isMax: boolean) =>
isMax ? <MaxConnectionsIcon /> : <CustomIcon color={color} />
diff --git a/apps/studio/data/reports/database-charts.ts b/apps/studio/data/reports/database-charts.ts
index 7f5e7d81bab..d77ab807af9 100644
--- a/apps/studio/data/reports/database-charts.ts
+++ b/apps/studio/data/reports/database-charts.ts
@@ -44,7 +44,11 @@ export const getReportAttributesV2 = (org: Organization, project: Project) => {
showMaxValue: true,
showGrid: true,
syncId: 'database-reports',
- YAxisProps: { width: 60, tickFormatter: (value: any) => formatBytes(value, 0) },
+ valuePrecision: 2,
+ YAxisProps: {
+ width: 60,
+ tickFormatter: (value: any) => formatBytes(value, 2),
+ },
attributes: [
{
attribute: 'ram_usage_used',
@@ -71,6 +75,7 @@ export const getReportAttributesV2 = (org: Organization, project: Project) => {
attribute: 'ram_usage_swap',
provider: 'infra-monitoring',
label: 'Swap',
+ omitFromTotal: false, // we can set this to true if we want to omit the swap from the total
tooltip:
'Memory swapped to disk when RAM is full. An instance has 1GB of SWAP. High swap with high disk I/O signals memory stress.',
},