Spaces:
Sleeping
Sleeping
| /** | |
| * VehicleCountChart β area chart of vehicles-in-frame over the last 60 frames. | |
| */ | |
| import { | |
| AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, | |
| } from 'recharts' | |
| export default function VehicleCountChart({ history }) { | |
| const data = history.map((m, i) => ({ | |
| t: i, | |
| count: m.vehicles_in_frame ?? 0, | |
| })) | |
| return ( | |
| <div className="bg-gray-800 border border-gray-700 rounded-xl p-4"> | |
| <h3 className="text-sm font-semibold text-gray-300 mb-3">Vehicles in Frame</h3> | |
| <ResponsiveContainer width="100%" height={180}> | |
| <AreaChart data={data} margin={{ top: 4, right: 8, left: -20, bottom: 0 }}> | |
| <defs> | |
| <linearGradient id="countGrad" x1="0" y1="0" x2="0" y2="1"> | |
| <stop offset="5%" stopColor="#3b82f6" stopOpacity={0.4} /> | |
| <stop offset="95%" stopColor="#3b82f6" stopOpacity={0} /> | |
| </linearGradient> | |
| </defs> | |
| <CartesianGrid strokeDasharray="3 3" stroke="#374151" /> | |
| <XAxis dataKey="t" hide /> | |
| <YAxis allowDecimals={false} tick={{ fill: '#9ca3af', fontSize: 11 }} /> | |
| <Tooltip | |
| contentStyle={{ background: '#1f2937', border: '1px solid #374151', borderRadius: 8 }} | |
| labelFormatter={() => ''} | |
| formatter={(v) => [v, 'vehicles']} | |
| /> | |
| <Area | |
| type="monotone" | |
| dataKey="count" | |
| stroke="#3b82f6" | |
| strokeWidth={2} | |
| fill="url(#countGrad)" | |
| dot={false} | |
| isAnimationActive={false} | |
| /> | |
| </AreaChart> | |
| </ResponsiveContainer> | |
| </div> | |
| ) | |
| } | |