Skip to content

Commit 9e6c036

Browse files
small fix for donut graphs not showing correct center percentage
1 parent 31265cb commit 9e6c036

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

entrypoints/degree-audit/components/degree-completion-donut.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useAuditContext } from "./audit-provider";
77
import { CATEGORY_COLORS } from "./requirement-breakdown";
88

99
const DegreeCompletionDonut = (styleProps: GraphStyleProps) => {
10-
const { progresses, completion } = useAuditContext();
10+
const { progresses } = useAuditContext();
1111
const bars = progresses.sections
1212
.filter((section) => section.progress.total > 0)
1313
.sort((a, b) => b.progress.total - a.progress.total)
@@ -17,7 +17,9 @@ const DegreeCompletionDonut = (styleProps: GraphStyleProps) => {
1717
percentage: section.progress,
1818
})) satisfies Bar[];
1919

20-
const overallPercentage = Math.round(completion);
20+
const overallPercentage = Math.round(
21+
(progresses.total.current / progresses.total.total) * 100,
22+
);
2123

2224
return (
2325
<MultiDonutGraph
@@ -37,7 +39,7 @@ const DegreeCompletionDonut = (styleProps: GraphStyleProps) => {
3739
<p>{bar.title}</p>
3840
<p>
3941
{Math.round(
40-
(bar.percentage.current / bar.percentage.total) * 100
42+
(bar.percentage.current / bar.percentage.total) * 100,
4143
)}
4244
%
4345
</p>
@@ -59,7 +61,7 @@ const DegreeCompletionDonut = (styleProps: GraphStyleProps) => {
5961
};
6062

6163
export const SimpleDegreeCompletionDonut = (styleProps: GraphStyleProps) => {
62-
const { progresses, completion } = useAuditContext();
64+
const { progresses } = useAuditContext();
6365
const bars = progresses.sections
6466
.filter((section) => section.progress.total > 0)
6567
.sort((a, b) => b.progress.total - a.progress.total)
@@ -69,7 +71,9 @@ export const SimpleDegreeCompletionDonut = (styleProps: GraphStyleProps) => {
6971
percentage: section.progress,
7072
})) satisfies Bar[];
7173

72-
const overallPercentage = Math.round(completion);
74+
const overallPercentage = Math.round(
75+
(progresses.total.current / progresses.total.total) * 100,
76+
);
7377

7478
return (
7579
<MultiDonutGraph {...styleProps} bars={bars}>

0 commit comments

Comments
 (0)