Skip to content

Commit 9dbff68

Browse files
committed
Prevent division by 0 in charts % calculation
1 parent ef77979 commit 9dbff68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ui/src/dashboard/Entry/DashboardPieChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const CustomTooltip = ({active, payload, total}: CustomTooltipProps) => {
4848
<Paper style={{padding: 10}} elevation={4}>
4949
<Typography>
5050
{first.payload.key}:{first.payload.value}: {prettyMs(first.payload.timeSpendInSeconds * 1000)} (
51-
{((first.payload.timeSpendInSeconds / total) * 100).toFixed(2)}%)
51+
{total > 0 ? ((first.payload.timeSpendInSeconds / total) * 100).toFixed(2) : '0.00'}%)
5252
</Typography>
5353
</Paper>
5454
);

0 commit comments

Comments
 (0)