mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { formatNumber } from '@/lib/fin';
|
|
|
|
const SimpleBarChart = ({
|
|
data,
|
|
title,
|
|
}: {
|
|
data: Array<{ label: string; value: number; color?: string }>;
|
|
title: string;
|
|
}) => {
|
|
const maxValue = Math.max(...data.map((d) => d.value), 1);
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
<h4 className="text-sm font-medium text-muted-foreground">{title}</h4>
|
|
<div className="space-y-2">
|
|
{data.map((item, index) => (
|
|
<div key={index} className="flex items-center gap-3">
|
|
<span className="text-sm min-w-16 truncate">{item.label}</span>
|
|
<div className="flex-1 bg-muted rounded-full h-2">
|
|
<div
|
|
className="h-2 rounded-full transition-all duration-500"
|
|
style={{
|
|
width: `${(item.value / maxValue) * 100}%`,
|
|
backgroundColor: item.color || 'hsl(var(--primary))',
|
|
}}
|
|
/>
|
|
</div>
|
|
<span className="text-sm font-medium min-w-12 text-right">
|
|
{formatNumber(item.value)}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SimpleBarChart;
|