mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-04-07 11:03:37 +00:00
40 lines
1.0 KiB
TypeScript
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 },
|
|
},
|
|
}}
|
|
/>
|
|
);
|
|
}
|