diff --git a/frontend/src/components/ApplicationChart.tsx b/frontend/src/components/ApplicationChart.tsx new file mode 100644 index 00000000..dfef0bda --- /dev/null +++ b/frontend/src/components/ApplicationChart.tsx @@ -0,0 +1,47 @@ +"use client"; + +import React from "react"; +import { Pie } from "react-chartjs-2"; +import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js"; + +ChartJS.register(ArcElement, Tooltip, Legend); + +interface ApplicationChartProps { + data: { nsapp: string }[]; +} + +const ApplicationChart: React.FC = ({ data }) => { + const chartData = () => { + const appCounts: Record = {}; + + data.forEach((item) => { + appCounts[item.nsapp] = (appCounts[item.nsapp] || 0) + 1; + }); + + return { + labels: Object.keys(appCounts), + datasets: [ + { + label: "Applications", + data: Object.values(appCounts), + backgroundColor: [ + "#ff6384", + "#36a2eb", + "#ffce56", + "#4bc0c0", + "#9966ff", + "#ff9f40", + ], + }, + ], + }; + }; + + return ( +
+ +
+ ); +}; + +export default ApplicationChart;