import React from 'react'; import { motion } from 'framer-motion'; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, ReferenceLine } from 'recharts'; import { Clock, AlertCircle, TrendingUp } from 'lucide-react'; interface HourlyDistributionChartProps { hourly: number[]; off_hours_pct: number; peak_hours: number[]; } export function HourlyDistributionChart({ hourly, off_hours_pct, peak_hours }: HourlyDistributionChartProps) { // Preparar datos para el gráfico const chartData = hourly.map((value, hour) => ({ hour: `${hour}:00`, hourNum: hour, volume: value, isPeak: peak_hours.includes(hour), isOffHours: hour < 8 || hour >= 19 })); const totalVolume = hourly.reduce((a, b) => a + b, 0); const peakVolume = Math.max(...hourly); const avgVolume = totalVolume / 24; // Custom tooltip const CustomTooltip = ({ active, payload }: any) => { if (active && payload && payload.length) { const data = payload[0].payload; return (
{data.hour}
Volumen: {data.volume.toLocaleString('es-ES')}
% del total: {((data.volume / totalVolume) * 100).toFixed(1)}%
{data.isPeak && (⚡ Hora pico
)} {data.isOffHours && (🌙 Fuera de horario
)}Análisis del volumen de interacciones por hora del día
Alto volumen fuera de horario laboral
El {(off_hours_pct * 100).toFixed(0)}% de las interacciones ocurren fuera del horario laboral estándar (19:00-08:00). Considera implementar cobertura 24/7 con agentes virtuales para mejorar la experiencia del cliente y reducir costes.