diff --git a/src/components/CommunityPortal/Reports/Participation/ChartsSection.jsx b/src/components/CommunityPortal/Reports/Participation/ChartsSection.jsx new file mode 100644 index 0000000000..e3f85d5ac2 --- /dev/null +++ b/src/components/CommunityPortal/Reports/Participation/ChartsSection.jsx @@ -0,0 +1,146 @@ +import { useSelector } from 'react-redux'; +import { + BarChart, + Bar, + XAxis, + YAxis, + Tooltip, + ResponsiveContainer, + LineChart, + Line, + PieChart, + Pie, + Cell, + Legend, +} from 'recharts'; + +import mockEvents from './mockData'; +import styles from './ChartsSection.module.css'; + +function ChartsSection() { + const darkMode = useSelector(state => state.theme.darkMode); + + // Group data by event type + const eventTypeStats = []; + const groups = {}; + + mockEvents.forEach(evt => { + const key = evt.eventType; + + if (!groups[key]) { + groups[key] = { count: 0, noShowSum: 0, dropSum: 0 }; + } + + groups[key].count++; + groups[key].noShowSum += parseInt(evt.noShowRate, 10); + groups[key].dropSum += parseInt(evt.dropOffRate, 10); + }); + + for (const key in groups) { + eventTypeStats.push({ + eventType: key, + avgNoShow: Math.round(groups[key].noShowSum / groups[key].count), + avgDrop: Math.round(groups[key].dropSum / groups[key].count), + }); + } + + // Monthly trend + const monthlyTrend = {}; + + mockEvents.forEach(evt => { + const m = new Date(evt.eventDate).getMonth(); + + if (!monthlyTrend[m]) { + monthlyTrend[m] = { count: 0, noShowSum: 0 }; + } + + monthlyTrend[m].count++; + monthlyTrend[m].noShowSum += parseInt(evt.noShowRate, 10); + }); + + const trendData = Object.keys(monthlyTrend).map(m => ({ + month: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][m], + avgNoShow: Math.round(monthlyTrend[m].noShowSum / monthlyTrend[m].count), + })); + + // Location distribution + const locationGroups = {}; + + mockEvents.forEach(evt => { + const loc = evt.location; + if (!locationGroups[loc]) locationGroups[loc] = 0; + locationGroups[loc]++; + }); + + const locationData = Object.keys(locationGroups).map(loc => ({ + name: loc, + value: locationGroups[loc], + })); + + const pieColors = ['#007bff', '#00b894', '#e17055', '#6c5ce7', '#fdcb6e']; + + return ( +
Charts and breakdowns for age, gender, and location demographics will appear here.
++5% Last week
- No-show rate + No-show rate
| Event name | @@ -108,6 +109,7 @@ function DropOffTracking() {Attendees |
|---|---|