diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/SurveyedResultsPieChart.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/SurveyedResultsPieChart.tsx index d31bcd51..df1bda9e 100644 --- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/SurveyedResultsPieChart.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/SurveyedResultsPieChart.tsx @@ -24,6 +24,17 @@ export default function SurveyedPieChart({ "Rescheduled", ]; + const colors = [ + "indigo-600", + "indigo-400", + "blue-300", + "amber-400", + "amber-200", + "slate-400", + "gray-300", + "gray-100", + ]; + const data = useMemo(() => { const outcomeCounts: Record = {}; deals.forEach((deal) => { @@ -32,9 +43,11 @@ export default function SurveyedPieChart({ outcomeCounts[outcome] = (outcomeCounts[outcome] || 0) + 1; } }); + const total = Object.values(outcomeCounts).reduce((a, b) => a + b, 0); return Object.entries(outcomeCounts).map(([name, amount]) => ({ name, amount, + percentage: total ? ((amount / total) * 100).toFixed(1) : "0.0", })); }, [deals]); @@ -45,35 +58,54 @@ export default function SurveyedPieChart({ }; return ( - -
- - Survey Outcomes - -

- Click a segment to view filtered properties -

+ + {/* Header */} +
+ + Survey Performance + +

+ Click a segment or label to view filtered properties +

+
- `${n.toLocaleString()}`} - colors={[ - "#2d348f", - "#14163d", - "#3943b7", - "#5d6be0", - "black", - "#eff6fc", - "lightBlue", - "navy", - "azure", - ]} - className="w-64 h-64 cursor-pointer transition-transform hover:scale-[1.03]" - onValueChange={handleClick} - /> + {/* Chart */} +
+ `${n.toLocaleString()}`} + colors={colors} + onValueChange={handleClick} + showLabel={false} + className="w-64 h-64 cursor-pointer" + customTooltip={({ payload }) => { + const item = payload?.[0]?.payload; + if (!item) return null; + const { name, amount } = item; + return ( +
+
+ {name} + {amount.toLocaleString()} +
+
+ ); + }} + /> + {data.length > 0 && ( +
+ + {data.reduce((a, b) => a + b.amount, 0)} +
- + )} +
+
+ ); }