export interface ChartLegendItem { label: string; color: string; dataKey?: string; } interface ChartLegendProps { items: ChartLegendItem[]; selectedItem?: string | null; onItemClick?: (dataKey: string) => void; } export function ChartLegend({ items, selectedItem, onItemClick, }: ChartLegendProps) { const isInteractive = !!onItemClick; return (
{items.map((item, index) => { const dataKey = item.dataKey ?? item.label.toLowerCase(); const isSelected = selectedItem === dataKey; const isFaded = selectedItem !== null && !isSelected; return ( ); })}
); }