Review

Responsive multi-series cold-chain chart

Pharmacy cold-chain ops dashboard was clipping the 14-day excursion chart on narrow viewports and remounting series on every poll. Wraps the LineChart in ResponsiveContainer and keys each series by depot id so color and animation stay stable when the series list reorders.

RechartsTier 1frontendcharts

Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.

components/ops/ColdChainExcursionChart.tsx+7-5
1818type DepotSeries = { id: string; label: string; color: string; dataKey: string };
1919
2020export function ColdChainExcursionChart({
2121 points,
2222 series,
2323}: {
2424 points: Array<Record<string, string | number>>;
2525 series: DepotSeries[];
2626}) {
2727 return (
28- <div className="h-72 w-full overflow-hidden">
29- <LineChart width={640} height={288} data={points}>
28+ <div className="h-72 w-full">
29+ <ResponsiveContainer width="100%" height="100%">
30+ <LineChart data={points}>
3031 <XAxis dataKey="day" tickMargin={8} />
3132 <YAxis allowDecimals={false} />
3233 <Tooltip />
3334 <Legend />
34- {series.map((s, i) => (
35- <Line key={i} type="monotone" dataKey={s.dataKey} name={s.label} stroke={s.color} />
35+ {series.map((s) => (
36+ <Line key={s.id} type="monotone" dataKey={s.dataKey} name={s.label} stroke={s.color} dot={false} />
3637 ))}
37- </LineChart>
38+ </LineChart>
39+ </ResponsiveContainer>
3840 </div>
3941 );
4042}