Skip to content

Commit 665c912

Browse files
x0sinaImMohammad20000
authored andcommitted
fix(charts): correct total usage calculation in tooltip and node stats modal
1 parent d72f0e0 commit 665c912

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

dashboard/src/components/charts/all-nodes-stacked-bar-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function CustomTooltip({ active, payload, chartConfig, dir, period }: TooltipPro
165165
<div className={`mb-1.5 flex items-center justify-center gap-1.5 text-center text-[10px] text-muted-foreground sm:text-xs`}>
166166
<span>{t('statistics.totalUsage', { defaultValue: 'Total' })}: </span>
167167
<span dir="ltr" className="inline-block truncate font-mono">
168-
{nodesToShow.reduce((sum, node) => sum + node.usage, 0).toFixed(2)}
168+
{activeNodes.reduce((sum, node) => sum + node.usage, 0).toFixed(2)}
169169
GB
170170
</span>
171171
</div>

dashboard/src/components/dialogs/node-stats-modal.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ const NodeStatsModal = ({ open, onClose, data, chartConfig, period, allChartData
143143
const canGoLeft = isRTL ? canGoNext : canGoPrevious
144144
const canGoRight = isRTL ? canGoPrevious : canGoNext
145145

146-
// Calculate total usage
147-
const totalUsage = Object.keys(data).reduce((sum, key) => {
148-
if (key.startsWith('_uplink_') || key.startsWith('_downlink_') || key === 'time' || key === '_period_start') return sum
149-
return sum + (data[key] || 0)
150-
}, 0)
151-
152146
// Calculate total uplink and downlink
153147
const totalUplink = Object.keys(data)
154148
.filter(key => key.startsWith('_uplink_'))
@@ -206,7 +200,7 @@ const NodeStatsModal = ({ open, onClose, data, chartConfig, period, allChartData
206200
</span>
207201
</div>
208202
<Badge dir="ltr" variant="secondary" className="px-2 py-1 font-mono text-xs sm:text-sm">
209-
{totalUsage.toFixed(2)} GB
203+
{formatBytes(totalUplink + totalDownlink)}
210204
</Badge>
211205
</div>
212206

0 commit comments

Comments
 (0)