diff --git a/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.jsx b/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.jsx index bf3f82c9d8..671c941537 100644 --- a/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.jsx +++ b/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.jsx @@ -2,16 +2,14 @@ import PropTypes from 'prop-types'; import { Doughnut } from 'react-chartjs-2'; import ChartDataLabels from 'chartjs-plugin-datalabels'; import { Chart, ArcElement } from 'chart.js'; -import './VolunteerStatusPieChart.css'; +import styles from './VolunteerStatusPieChart.module.css'; -Chart.register(ArcElement); +Chart.register(ArcElement, ChartDataLabels); function VolunteerStatusPieChart({ data: { totalVolunteers, percentageChange, data: volunteerData }, comparisonType, }) { - // Debug: Log the data used for the chart - // console.log('VolunteerStatusPieChart data:', { volunteerData, totalVolunteers }); const chartData = { labels: volunteerData.map(item => item.label), datasets: [ @@ -28,43 +26,45 @@ function VolunteerStatusPieChart({ datalabels: { color: '#000', font: { - size: 20, - weight: 'bolder', - lineHeight: 1.8, + size: 16, + weight: 'bold', + lineHeight: 1.4, }, - formatter: function(value, context) { - const percentage = ((value / totalVolunteers) * 100).toFixed(0); - // Show value and percent as two lines for clarity - return [`${value}`, `(${percentage}%)`]; + formatter(value) { + const percentage = (value / totalVolunteers) * 100; + // Only show labels for slices >= 10% + if (percentage < 10) return ''; + return `${value} (${percentage.toFixed(0)}%)`; }, display: true, - offset: 0, - align: 'center', anchor: 'center', + align: 'center', + offset: 0, + clamp: true, }, - legend: { - display: false, - }, - tooltip: { - enabled: false, - }, + legend: { display: false }, + tooltip: { enabled: false }, }, maintainAspectRatio: false, - cutout: '55%', + cutout: '65%', }; const percentageChangeColor = percentageChange >= 0 ? 'green' : 'red'; return ( -
-
- -
-

TOTAL VOLUNTEERS

-

{totalVolunteers}

+
+
+ +
+

TOTAL VOLUNTEERS

+

{totalVolunteers}

{comparisonType !== 'No Comparison' && (

@@ -75,17 +75,26 @@ function VolunteerStatusPieChart({ )}

-
- {volunteerData.map((item, index) => ( -
-
- ))} + +
+ {volunteerData.map((item, index) => { + const percentage = ((item.value / totalVolunteers) * 100).toFixed(1); + return ( +
+
+ ); + })}
); diff --git a/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.css b/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.module.css similarity index 61% rename from src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.css rename to src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.module.css index da4fed0d08..831a6d49b9 100644 --- a/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.css +++ b/src/components/TotalOrgSummary/VolunteerStatus/VolunteerStatusPieChart.module.css @@ -1,4 +1,4 @@ -.volunteer-status-container { +.volunteerStatusContainer { display: flex; flex-direction: column; align-items: center; @@ -6,14 +6,42 @@ width: 100%; } -.volunteer-status-chart { +.volunteerStatusChart { position: relative; width: 100%; max-width: 400px; height: 400px; } -.volunteer-status-center { +.volunteerStatusLabels { + display: flex; + justify-content: center; + gap: 24px; + margin-top: 20px; + margin-bottom: 50px; + flex-wrap: wrap; +} + +.volunteerStatusLabel { + display: flex; + align-items: center; + gap: 6px; + font-size: 14px; +} + +.volunteerStatusValue { + font-weight: 600; +} + +.volunteerStatusColor { + display: inline-block; + width: 12px; + height: 12px; + margin-right: 5px; +} + +/* Center text inside the donut */ +.volunteerStatusCenter { position: absolute; top: 50%; left: 50%; @@ -22,41 +50,19 @@ font-size: 14px; } -.volunteer-status-center .volunteer-status-heading { +.volunteerStatusHeading { color: #828282; font-size: 1.2rem; } -.volunteer-status-center .volunteer-count { +.volunteerCount { color: #6c6c6c; font-size: 2rem; font-weight: bolder; } -.volunteer-status-center > p { +/* Optional: style for comparison text */ +.percentageChange { font-weight: bold; -} - -.volunteer-status-center div { - margin: 2px 0; -} - -.volunteer-status-labels { - display: flex; - justify-content: center; - margin-top: 20px; - margin-bottom: 50px; -} - -.volunteer-status-label { - display: flex; - align-items: center; - margin: 0 10px; -} - -.volunteer-status-color { - display: inline-block; - width: 12px; - height: 12px; - margin-right: 5px; + margin-top: 4px; } diff --git a/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsLineChart.jsx b/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsLineChart.jsx index 4587310aba..2ea8ca2dce 100644 --- a/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsLineChart.jsx +++ b/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsLineChart.jsx @@ -1,4 +1,12 @@ -import { LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip } from 'recharts'; +import { + LineChart, + Line, + CartesianGrid, + XAxis, + YAxis, + Tooltip, + ResponsiveContainer, +} from 'recharts'; import { useEffect, useState } from 'react'; import axios from 'axios'; import DatePicker from 'react-datepicker'; @@ -265,43 +273,46 @@ export default function VolunteerTrendsLineChart({ darkMode }) {
) : ( - - - - - - - +
+ + + + + + + + + + + + +
)} ); diff --git a/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsStyles.module.css b/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsStyles.module.css index f20999bc9c..f905f7a9ba 100644 --- a/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsStyles.module.css +++ b/src/components/TotalOrgSummary/VolunteerTrendsLineChart/VolunteerTrendsStyles.module.css @@ -11,13 +11,15 @@ } .chartContainer { - display: grid; - justify-content: center; - text-align: center; - padding: 10px; - position: relative; + width: 100%; + padding: 10px 0 15px; margin-top: 20px; margin-bottom: 15px; + + display: flex; + flex-direction: column; + align-items: stretch; + text-align: left; } .customDateRange { @@ -32,7 +34,7 @@ display: flex; gap: 10px; align-items: center; - justify-content: center; + justify-content: flex-start; } .dateFilterContainer > select {