import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, ReferenceLine, } from 'recharts'; import type { SensorLog } from '../types'; interface Props { data: SensorLog[]; currentTime: number; startTime: number; endTime: number; } export function SensorChart({ data, currentTime, startTime }: Props) { const { t } = useTranslation(); const visibleData = useMemo( () => data.filter(d => d.timestamp <= currentTime), [data, currentTime], ); const chartData = useMemo( () => visibleData.map(d => ({ ...d, time: formatHour(d.timestamp, startTime), })), [visibleData, startTime], ); return (

{t('sensor.title')}

{t('sensor.seismicActivity')}

{t('sensor.noiseLevelDb')}

{t('sensor.airPressureHpa')}

{t('sensor.radiationUsv')}

); } function formatHour(timestamp: number, startTime: number): string { const hours = (timestamp - startTime) / 3600_000; const h = Math.floor(hours); const m = Math.round((hours - h) * 60); return `${h}:${m.toString().padStart(2, '0')}`; }