update types

This commit is contained in:
chark1es 2025-04-11 17:37:32 -07:00
parent effb8e22d7
commit f2bbd65db5

View file

@ -26,12 +26,12 @@ ChartJS.register(
// Define event types and their colors // Define event types and their colors
const EVENT_TYPES = [ const EVENT_TYPES = [
{ name: 'Technical Workshop', color: 'rgba(54, 162, 235, 0.8)' }, { name: 'Social', key: 'social', color: 'rgba(255, 99, 132, 0.8)' },
{ name: 'Social', color: 'rgba(255, 99, 132, 0.8)' }, { name: 'Technical', key: 'technical', color: 'rgba(54, 162, 235, 0.8)' },
{ name: 'Professional Development', color: 'rgba(75, 192, 192, 0.8)' }, { name: 'Outreach', key: 'outreach', color: 'rgba(255, 206, 86, 0.8)' },
{ name: 'Project Meeting', color: 'rgba(255, 206, 86, 0.8)' }, { name: 'Professional', key: 'professional', color: 'rgba(75, 192, 192, 0.8)' },
{ name: 'Industry Talk', color: 'rgba(153, 102, 255, 0.8)' }, { name: 'Projects', key: 'projects', color: 'rgba(153, 102, 255, 0.8)' },
{ name: 'Other', color: 'rgba(255, 159, 64, 0.8)' }, { name: 'Other', key: 'other', color: 'rgba(255, 159, 64, 0.8)' },
]; ];
export default function EventTypeDistribution() { export default function EventTypeDistribution() {
@ -118,29 +118,12 @@ export default function EventTypeDistribution() {
return acc; return acc;
}, {} as Record<string, number>); }, {} as Record<string, number>);
// Count events by event_type field from schema
events.forEach(event => { events.forEach(event => {
const eventName = event.event_name.toLowerCase(); const type = event.event_type && EVENT_TYPES.find(t => t.key === event.event_type) ? event.event_type : 'other';
const eventDesc = event.event_description.toLowerCase(); const typeObj = EVENT_TYPES.find(t => t.key === type);
if (typeObj) {
// Simple classification logic - in a real app, you'd have actual event types eventTypeCount[typeObj.name]++;
if (eventName.includes('workshop') || eventDesc.includes('workshop')) {
eventTypeCount['Technical Workshop']++;
} else if (eventName.includes('social') || eventDesc.includes('social') ||
eventName.includes('mixer') || eventDesc.includes('mixer')) {
eventTypeCount['Social']++;
} else if (eventName.includes('professional') || eventDesc.includes('professional') ||
eventName.includes('resume') || eventDesc.includes('resume') ||
eventName.includes('career') || eventDesc.includes('career')) {
eventTypeCount['Professional Development']++;
} else if (eventName.includes('project') || eventDesc.includes('project') ||
eventName.includes('meeting') || eventDesc.includes('meeting')) {
eventTypeCount['Project Meeting']++;
} else if (eventName.includes('industry') || eventDesc.includes('industry') ||
eventName.includes('talk') || eventDesc.includes('talk') ||
eventName.includes('speaker') || eventDesc.includes('speaker')) {
eventTypeCount['Industry Talk']++;
} else {
eventTypeCount['Other']++;
} }
}); });
@ -180,11 +163,8 @@ export default function EventTypeDistribution() {
tooltip: { tooltip: {
callbacks: { callbacks: {
label: function (context: any) { label: function (context: any) {
const label = context.label || ''; // Only show the label, not the value
const value = context.raw || 0; return context.label || '';
const total = context.dataset.data.reduce((a: number, b: number) => a + b, 0);
const percentage = Math.round((value / total) * 100);
return `${label}: ${value} (${percentage}%)`;
} }
} }
} }