Files
livedash-node/components/security/SecurityMetricsChart.tsx
Kaj Kowalski 1eea2cc3e4 refactor: fix biome linting issues and update project documentation
- Fix 36+ biome linting issues reducing errors/warnings from 227 to 191
- Replace explicit 'any' types with proper TypeScript interfaces
- Fix React hooks dependencies and useCallback patterns
- Resolve unused variables and parameter assignment issues
- Improve accessibility with proper label associations
- Add comprehensive API documentation for admin and security features
- Update README.md with accurate PostgreSQL setup and current tech stack
- Create complete documentation for audit logging, CSP monitoring, and batch processing
- Fix outdated project information and missing developer workflows
2025-07-12 00:28:09 +02:00

72 lines
1.6 KiB
TypeScript

"use client";
import {
Bar,
BarChart,
Line,
LineChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from "recharts";
interface SecurityMetricsChartProps {
data: Array<{ hour: number; count: number }>;
type?: "line" | "bar";
title?: string;
}
export function SecurityMetricsChart({
data,
type = "line",
title,
}: SecurityMetricsChartProps) {
const chartData = data.map((item) => ({
hour: `${item.hour}:00`,
count: item.count,
}));
const ChartComponent = type === "line" ? LineChart : BarChart;
const DataComponent =
type === "line" ? (
<Line
type="monotone"
dataKey="count"
stroke="#8884d8"
strokeWidth={2}
dot={{ fill: "#8884d8", strokeWidth: 2 }}
/>
) : (
<Bar dataKey="count" fill="#8884d8" />
);
return (
<div className="space-y-2">
{title && <h3 className="text-lg font-semibold">{title}</h3>}
<ResponsiveContainer width="100%" height={300}>
<ChartComponent data={chartData}>
<XAxis
dataKey="hour"
tick={{ fontSize: 12 }}
tickLine={{ stroke: "#e5e7eb" }}
/>
<YAxis
tick={{ fontSize: 12 }}
tickLine={{ stroke: "#e5e7eb" }}
axisLine={{ stroke: "#e5e7eb" }}
/>
<Tooltip
contentStyle={{
backgroundColor: "#f9fafb",
border: "1px solid #e5e7eb",
borderRadius: "6px",
}}
/>
{DataComponent}
</ChartComponent>
</ResponsiveContainer>
</div>
);
}