import React from "react"; import { formatNumber } from "~/lib/utils"; import { Tooltip, TooltipContent, TooltipTrigger, } from "~/components/ui/tooltip" interface DataItem { label: string; value: number; color: string; } interface DashboardCustomBarChartProps { title: string; data: DataItem[]; loading?: boolean; } export function DashboardCustomBarChart({ title, data, loading = false, }: DashboardCustomBarChartProps) { if (loading) { return (

{title}

{[1, 2, 3].map((i) => (
))}
); } // Calculate the maximum value for scaling const maxValue = Math.max(...data.map((item) => item.value)); return (

{title}

{data.map((item, index) => { const widthPercentage = maxValue > 0 ? (item.value / maxValue) * 100 : 0; return (
{/* Bar container */}
{/* Animated bar */}
{ widthPercentage > 20 ? ( {item.label} ) : ( ""

{item.label}

) }
{formatNumber(item.value)}
); })}
); }