Skip to content

Commit 100b342

Browse files
committed
percentage ipv count
1 parent 85df38b commit 100b342

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/DistributionReport.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ function countCategory2ForCategory1(
2121
const count = data.filter(
2222
row => row[column1] === category1 && row[column2] === category2
2323
).length;
24-
return count;
24+
25+
const total = data.filter(row => row[column1] === category1).length;
26+
if (total === 0) {
27+
return 0;
28+
}
29+
return (count / total) * 100;
2530
}
2631

2732
interface DistributionReport {
@@ -328,7 +333,7 @@ export const DistributionReport = (
328333
>
329334
<GroupBarChart
330335
yAxisLabel={t(
331-
'distribution.frequency'
336+
'distribution.percentage'
332337
)}
333338
title={`${column} = ${item}`}
334339
data={categories2.map(

0 commit comments

Comments
 (0)