Skip to content

Commit 3d46c29

Browse files
committed
fix: update total mentors donut chart to use new donutChartData structure
1 parent 15a5f85 commit 3d46c29

4 files changed

Lines changed: 62 additions & 24 deletions

File tree

src/components/TotalOrgSummary/VolunteerStatus/MentorStatusPieChart.module.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@
5757
justify-content: center;
5858
align-items: center;
5959
gap: 16px;
60-
margin-top: 28px;
61-
flex-wrap: wrap;
60+
margin-top: 48px;
61+
margin-bottom: 24px;
62+
flex-wrap: nowrap;
63+
padding: 0 20px;
64+
width: max-content;
65+
max-width: 100%;
66+
box-sizing: border-box;
6267
}
6368

6469
.mentorStatusLabel {

src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusChart.jsx

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,33 @@ function VolunteerStatusChart({
5454
return null;
5555
}
5656

57-
const { activeMentors, deactivatedMentors, newMentors, totalMentors } = mentorNumberStats;
57+
const {
58+
donutChartData,
59+
activeMentors,
60+
deactivatedMentors,
61+
newMentors,
62+
totalMentors,
63+
} = mentorNumberStats;
5864

59-
return {
60-
totalMentors: totalMentors.count,
61-
percentageChange: Number(totalMentors.comparisonPercentage) || 0,
62-
data: [
65+
let chartDataValues;
66+
if (donutChartData && donutChartData.existingActive !== undefined) {
67+
chartDataValues = [
68+
{ label: 'Existing Active', value: donutChartData.existingActive.count },
69+
{ label: 'New Active', value: donutChartData.newActive.count },
70+
{ label: 'Deactivated', value: donutChartData.deactivated.count },
71+
];
72+
} else {
73+
chartDataValues = [
6374
{ label: 'Active', value: activeMentors.count },
6475
{ label: 'New', value: newMentors.count },
6576
{ label: 'Deactivated This Week', value: deactivatedMentors.count },
66-
],
77+
];
78+
}
79+
80+
return {
81+
totalMentors: totalMentors.count,
82+
percentageChange: Number(totalMentors.comparisonPercentage) || 0,
83+
data: chartDataValues,
6784
};
6885
}, [mentorNumberStats]);
6986

@@ -132,6 +149,32 @@ VolunteerStatusChart.propTypes = {
132149
comparisonPercentage: PropTypes.number,
133150
}),
134151
}),
152+
mentorNumberStats: PropTypes.shape({
153+
donutChartData: PropTypes.shape({
154+
existingActive: PropTypes.shape({
155+
count: PropTypes.number,
156+
}),
157+
newActive: PropTypes.shape({
158+
count: PropTypes.number,
159+
}),
160+
deactivated: PropTypes.shape({
161+
count: PropTypes.number,
162+
}),
163+
}),
164+
activeMentors: PropTypes.shape({
165+
count: PropTypes.number,
166+
}),
167+
newMentors: PropTypes.shape({
168+
count: PropTypes.number,
169+
}),
170+
deactivatedMentors: PropTypes.shape({
171+
count: PropTypes.number,
172+
}),
173+
totalMentors: PropTypes.shape({
174+
count: PropTypes.number,
175+
comparisonPercentage: PropTypes.number,
176+
}),
177+
}),
135178
};
136179

137180
export default VolunteerStatusChart;

src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.jsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,8 @@ function VolunteerStatusPieChart({
2626
const options = {
2727
plugins: {
2828
datalabels: {
29-
color: '#000',
30-
font: {
31-
size: 20,
32-
weight: 'bolder',
33-
lineHeight: 1.8,
34-
},
35-
formatter: function(value, context) {
36-
const percentage = ((value / totalVolunteers) * 100).toFixed(0);
37-
// Show value and percent as two lines for clarity
38-
return [`${value}`, `(${percentage}%)`];
39-
},
40-
display: true,
41-
offset: 0,
42-
align: 'center',
43-
anchor: 'center',
29+
// Hide in-slice labels because values are already shown with external guides.
30+
display: false,
4431
},
4532
legend: {
4633
display: false,

src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.module.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@
5151
align-items: center;
5252
gap: 16px;
5353
margin-top: 32px;
54-
flex-wrap: wrap;
54+
flex-wrap: nowrap;
5555
margin-bottom: 24px;
56+
overflow-x: auto;
57+
padding: 0 8px;
58+
width: 100%;
5659
}
5760

5861
.volunteerStatusLabel {

0 commit comments

Comments
 (0)