Spaces:
Build error
Build error
Upload components/RevenueChart.jsx with huggingface_hub
Browse files- components/RevenueChart.jsx +80 -0
components/RevenueChart.jsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import {
|
| 3 |
+
LineChart,
|
| 4 |
+
Line,
|
| 5 |
+
XAxis,
|
| 6 |
+
YAxis,
|
| 7 |
+
CartesianGrid,
|
| 8 |
+
Tooltip,
|
| 9 |
+
ResponsiveContainer,
|
| 10 |
+
AreaChart,
|
| 11 |
+
Area
|
| 12 |
+
} from 'recharts';
|
| 13 |
+
|
| 14 |
+
const data = [
|
| 15 |
+
{ name: 'Jan', value: 4000 },
|
| 16 |
+
{ name: 'Feb', value: 3000 },
|
| 17 |
+
{ name: 'Mar', value: 5000 },
|
| 18 |
+
{ name: 'Apr', value: 4500 },
|
| 19 |
+
{ name: 'May', value: 6000 },
|
| 20 |
+
{ name: 'Jun', value: 5500 },
|
| 21 |
+
{ name: 'Jul', value: 7000 },
|
| 22 |
+
{ name: 'Aug', value: 6500 },
|
| 23 |
+
{ name: 'Sep', value: 8000 },
|
| 24 |
+
{ name: 'Oct', value: 7500 },
|
| 25 |
+
{ name: 'Nov', value: 9000 },
|
| 26 |
+
{ name: 'Dec', value: 10000 },
|
| 27 |
+
];
|
| 28 |
+
|
| 29 |
+
function CustomTooltip({ active, payload, label }) {
|
| 30 |
+
if (active && payload && payload.length) {
|
| 31 |
+
return (
|
| 32 |
+
<div className="bg-white dark:bg-dark-surface p-3 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg">
|
| 33 |
+
<p className="text-xs text-gray-500 dark:text-gray-400">{label}</p>
|
| 34 |
+
<p className="text-sm font-bold text-gray-900 dark:text-white">
|
| 35 |
+
${payload[0].value.toLocaleString()}
|
| 36 |
+
</p>
|
| 37 |
+
</div>
|
| 38 |
+
);
|
| 39 |
+
}
|
| 40 |
+
return null;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
export default function RevenueChart() {
|
| 44 |
+
return (
|
| 45 |
+
<div className="w-full h-full">
|
| 46 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 47 |
+
<AreaChart data={data}>
|
| 48 |
+
<defs>
|
| 49 |
+
<linearGradient id="colorValue" x1="0" y1="0" x2="0" y2="1">
|
| 50 |
+
<stop offset="5%" stopColor="#3b82f6" stopOpacity={0.3}/>
|
| 51 |
+
<stop offset="95%" stopColor="#3b82f6" stopOpacity={0}/>
|
| 52 |
+
</linearGradient>
|
| 53 |
+
</defs>
|
| 54 |
+
<CartesianGrid strokeDasharray="3 3" stroke="#e5e7eb" vertical={false} className="dark:stroke-gray-700" />
|
| 55 |
+
<XAxis
|
| 56 |
+
dataKey="name"
|
| 57 |
+
axisLine={false}
|
| 58 |
+
tickLine={false}
|
| 59 |
+
tick={{ fill: '#9ca3af', fontSize: 12 }}
|
| 60 |
+
/>
|
| 61 |
+
<YAxis
|
| 62 |
+
axisLine={false}
|
| 63 |
+
tickLine={false}
|
| 64 |
+
tick={{ fill: '#9ca3af', fontSize: 12 }}
|
| 65 |
+
tickFormatter={(value) => `$${value / 1000}k`}
|
| 66 |
+
/>
|
| 67 |
+
<Tooltip content={<CustomTooltip />} cursor={{ fill: 'transparent' }} />
|
| 68 |
+
<Area
|
| 69 |
+
type="monotone"
|
| 70 |
+
dataKey="value"
|
| 71 |
+
stroke="#3b82f6"
|
| 72 |
+
strokeWidth={2}
|
| 73 |
+
fillOpacity={1}
|
| 74 |
+
fill="url(#colorValue)"
|
| 75 |
+
/>
|
| 76 |
+
</AreaChart>
|
| 77 |
+
</ResponsiveContainer>
|
| 78 |
+
</div>
|
| 79 |
+
);
|
| 80 |
+
}
|