diff --git a/frontend/app/components/Charts/utils.ts b/frontend/app/components/Charts/utils.ts index d3c633576..621fe2b85 100644 --- a/frontend/app/components/Charts/utils.ts +++ b/frontend/app/components/Charts/utils.ts @@ -228,7 +228,7 @@ function buildCompareTag(val: number, prevVal: number): string { const isHigher = delta > 0; const arrow = isHigher ? '▲' : '▼'; const absDelta = Math.abs(delta); - const ratio = prevVal !== 0 ? ((delta / prevVal) * 100).toFixed(2) : '∞'; + const ratio = prevVal !== 0 ? ((delta / prevVal) * 100).toFixed(2) : null; const tagColor = isHigher ? '#D1FADF' : '#FEE2E2'; const arrowColor = isHigher ? '#059669' : '#DC2626'; @@ -245,7 +245,7 @@ function buildCompareTag(val: number, prevVal: number): string { font-size: 0.75rem;"> ${arrow} ${absDelta} - (${ratio}%) + ${ratio ? `(${ratio}%)` : ''} `; } diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/BigNumChart.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/BigNumChart.tsx index 1fb18b285..05fb1b8c7 100644 --- a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/BigNumChart.tsx +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/BigNumChart.tsx @@ -48,6 +48,10 @@ function BigNum({ color, series, value, label, compData, valueLabel }: { if (!compData || compData === 0) return '0%'; return `${(((value - compData) / compData) * 100).toFixed(2)}%`; }, [value, compData]) + const change = React.useMemo(() => { + if (!compData) return 0; + return value - compData; + }, [value, compData]) return (