Skip to content

Commit b3ea452

Browse files
committed
Fix logic issue when getting minimum value.
The current logic will give minimum value as Infinity incase the array has all values as 0.
1 parent fb1c76c commit b3ea452

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/dashboard/components/analytics/map-component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export function MapComponent({
104104
const metricToUse = mode === 'perCapita' ? 'perCapita' : 'count';
105105
const values = processedCountryData?.map((d) => d[metricToUse]) || [0];
106106
const maxValue = Math.max(...values);
107-
const minValue = Math.min(...values.filter((v: number) => v > 0));
107+
const nonZeroValues = values.filter((v) => v > 0);
108+
const minValue = nonZeroValues.length > 0 ? Math.min(...nonZeroValues) : 0;
108109

109110
const baseBlue = '59, 130, 246';
110111
const lightBlue = '147, 197, 253';

0 commit comments

Comments
 (0)