diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 1afaa6d..f2097c0 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -1,6 +1,6 @@ import React, { useState, useMemo, useEffect } from 'react'; import { useSearchParams, Link } from 'react-router-dom'; -import { Line, Bar } from 'react-chartjs-2'; +import { Line, Bar, Pie } from 'react-chartjs-2'; import { Carousel, EmptyState, FilterControls, MultiSelect, StatCard } from './shared'; import { ExportableChart } from './ChartExport'; import { chartColors, chartPalette, createBaseOptions } from '../config/chartConfig'; @@ -79,6 +79,9 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels, const [activeChart, setActiveChart] = useState(0); const [trendGranularity, setTrendGranularity] = useState('week'); const [selectedSeason, setSelectedSeason] = useState(''); + const [eventMetric, setEventMetric] = useState<'visitors' | 'revenue'>('revenue'); + const [eventChartType, setEventChartType] = useState<'bar' | 'pie'>('bar'); + const [channelChartType, setChannelChartType] = useState<'bar' | 'pie'>('bar'); const filteredData = useMemo(() => filterData(data, filters), [data, filters]); @@ -400,6 +403,16 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels, const baseOptions = useMemo(() => createBaseOptions(showDataLabels), [showDataLabels]); + const pieOptions = useMemo(() => ({ + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { display: true, position: 'right' as const, labels: { boxWidth: 12, padding: 10, font: { size: 11 }, color: '#64748b' } }, + tooltip: baseOptions.plugins.tooltip, + datalabels: { display: false } + } + }), [baseOptions]); + // Season annotation bands for revenue trend chart const seasonAnnotations = useMemo(() => { const raw = trendData.rawDates; @@ -601,14 +614,27 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels,
- - - -
- -
- - + +
+ + +
+
+ + +
+
+ } + > + {eventChartType === 'bar' + ? + : + } @@ -619,8 +645,21 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels,
- - + + + +
+ } + > + {channelChartType === 'bar' + ? + : + } @@ -696,18 +735,22 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels,
-

{t('dashboard.visitorsByMuseum')}

-
- +

{eventMetric === 'visitors' ? t('dashboard.visitorsByMuseum') : t('dashboard.revenueByMuseum')}

+
+
+ + +
+
+ + +
-
-
- -
-
-

{t('dashboard.revenueByMuseum')}

- + {eventChartType === 'bar' + ? + : + }
@@ -724,8 +767,15 @@ function Dashboard({ data, seasons, userRole, showDataLabels, setShowDataLabels,

{t('dashboard.channelPerformance')}

+
+ + +
- + {channelChartType === 'bar' + ? + : + }
diff --git a/src/config/chartConfig.ts b/src/config/chartConfig.ts index 86b6cb2..a6a89cd 100644 --- a/src/config/chartConfig.ts +++ b/src/config/chartConfig.ts @@ -5,7 +5,7 @@ import { PointElement, LineElement, BarElement, - + ArcElement, Title, Tooltip, Legend, @@ -21,7 +21,7 @@ ChartJS.register( PointElement, LineElement, BarElement, - + ArcElement, Title, Tooltip, Legend, diff --git a/src/locales/ar.json b/src/locales/ar.json index 3e5b432..a7cdd0c 100644 --- a/src/locales/ar.json +++ b/src/locales/ar.json @@ -137,6 +137,8 @@ "addFirst": "أضف شريحتك الأولى", "slideTitle": "عنوان الشريحة", "chartType": "نوع الرسم البياني", + "bar": "أعمدة", + "pie": "دائري", "metric": "المقياس", "startDate": "تاريخ البداية", "endDate": "تاريخ النهاية", diff --git a/src/locales/en.json b/src/locales/en.json index 6d8dd81..3281a78 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -137,6 +137,8 @@ "addFirst": "Add your first slide", "slideTitle": "Slide Title", "chartType": "Chart Type", + "bar": "Bar", + "pie": "Pie", "metric": "Metric", "startDate": "Start Date", "endDate": "End Date",