Files
ahriman/frontend/src/components/charts/PackageCountBarChart.tsx
2026-02-27 16:45:24 +02:00

40 lines
1.0 KiB
TypeScript

import type React from "react";
import { Bar } from "react-chartjs-2";
import { Chart as ChartJS, CategoryScale, LinearScale, BarElement, Tooltip, Legend } from "chart.js";
import type { RepositoryStats } from "api/types/RepositoryStats";
ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
interface PackageCountBarChartProps {
stats: RepositoryStats;
}
export default function PackageCountBarChart({ stats }: PackageCountBarChartProps): React.JSX.Element {
const data = {
labels: ["packages"],
datasets: [
{
label: "archives",
data: [stats.packages ?? 0],
},
{
label: "bases",
data: [stats.bases ?? 0],
},
],
};
return (
<Bar
data={data}
options={{
maintainAspectRatio: false,
responsive: true,
scales: {
x: { stacked: true },
},
}}
/>
);
}