import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts'; import type { ProductDemandEntry } from '@/infrastructure/http/api/intelligence'; interface Props { products: ProductDemandEntry[]; mode: 'demand' | 'oos'; label: string; } export function HotDemandBarChart({ products, mode, label }: Props) { const data = products .map((p) => ({ name: p.productName ?? 'Unknown product', value: mode === 'oos' ? p.oosHits : p.demandHits })) .filter((d) => d.value > 0); if (data.length === 0) return null; const fill = mode === 'oos' ? '#d72c0d' : '#2a7'; const maxName = Math.max(120, ...data.map((d) => Math.min(220, d.name.length * 7))); return (
); }