diff --git a/frontend/src/components/application-chart.tsx b/frontend/src/components/application-chart.tsx deleted file mode 100644 index 0311754af..000000000 --- a/frontend/src/components/application-chart.tsx +++ /dev/null @@ -1,199 +0,0 @@ -"use client"; - -import { ArcElement, Chart as ChartJS, Tooltip as ChartTooltip, Legend } from "chart.js"; -import ChartDataLabels from "chartjs-plugin-datalabels"; -import { BarChart3, PieChart } from "lucide-react"; -import React, { useState } from "react"; -import { Pie } from "react-chartjs-2"; - -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip"; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; -import { Button } from "@/components/ui/button"; - -ChartJS.register(ArcElement, ChartTooltip, Legend, ChartDataLabels); - -type SummaryData = { - nsapp_count: Record; -}; - -type ApplicationChartProps = { - data: SummaryData | null; -}; - -const ITEMS_PER_PAGE = 20; -const CHART_COLORS = [ - "#ff6384", - "#36a2eb", - "#ffce56", - "#4bc0c0", - "#9966ff", - "#ff9f40", - "#4dc9f6", - "#f67019", - "#537bc4", - "#acc236", - "#166a8f", - "#00a950", - "#58595b", - "#8549ba", -]; - -export default function ApplicationChart({ data }: ApplicationChartProps) { - const [isChartOpen, setIsChartOpen] = useState(false); - const [isTableOpen, setIsTableOpen] = useState(false); - const [chartStartIndex, setChartStartIndex] = useState(0); - const [tableLimit, setTableLimit] = useState(ITEMS_PER_PAGE); - - if (!data) - return null; - - const sortedApps = Object.entries(data.nsapp_count) - .sort(([, a], [, b]) => b - a); - - const chartApps = sortedApps.slice( - chartStartIndex, - chartStartIndex + ITEMS_PER_PAGE, - ); - - const chartData = { - labels: chartApps.map(([name]) => name), - datasets: [ - { - data: chartApps.map(([, count]) => count), - backgroundColor: CHART_COLORS, - }, - ], - }; - - const chartOptions = { - plugins: { - legend: { display: false }, - datalabels: { - color: "white", - font: { weight: "bold" as const }, - formatter: (value: number, context: any) => { - const label = context.chart.data.labels?.[context.dataIndex]; - return `${label}\n(${value})`; - }, - }, - }, - responsive: true, - maintainAspectRatio: false, - }; - - return ( -
- - - - - - Open Chart View - - - - - - - Open Table View - - - - - - - Applications Distribution - -
- -
-
- - -
-
-
- - - - - Applications Count - -
- - - - Application - Count - - - - {sortedApps.slice(0, tableLimit).map(([name, count]) => ( - - {name} - {count} - - ))} - -
-
- {tableLimit < sortedApps.length && ( - - )} -
-
-
- ); -}