File size: 754 Bytes
a34cccb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {
  LineChart,
  Line,
  XAxis,
  Tooltip,
  ResponsiveContainer,
} from "recharts";

export default function ChartPanel({ data, metric }) {
  const formatted = data.timestamps.map((t, i) => ({
    time: new Date(t).toLocaleTimeString(),
    avg: data[metric].avg[i],
    max: data[metric].max[i],
    min: data[metric].min[i],
  }));

  return (
    <div className="h-64">

      <ResponsiveContainer>

        <LineChart data={formatted}>

          <XAxis dataKey="time" hide />

          <Tooltip />

          <Line dataKey="avg" stroke="#00ffcc" />

          <Line dataKey="max" stroke="#ff4d4f" />

          <Line dataKey="min" stroke="#8884d8" />

        </LineChart>

      </ResponsiveContainer>

    </div>
  );
}