[0d34a1]: / client / src / components / LineChart.jsx

Download this file

31 lines (29 with data), 1.3 kB

 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
31
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
function Chart(props) {
return (
<div>
<div className='text-center text-lg font-semibold' style={{color: props.color}}> {props.name} </div>
<div className='relative flex'>
<div className='absolute transform -rotate-90 -left-10 top-20 text-white/40'> {props.yname} </div>
<LineChart
width={900}
height={200}
data={props.data}
margin={{
top: 5,
right: 30,
left: 20,
bottom: 5,
}}
>
<CartesianGrid strokeDasharray="1 3 0" stroke='grey' horizontal={false} />
<XAxis dataKey="timestamp" />
<YAxis type="number" domain={props.range} />
<Line type="monotone" dataKey="value" stroke={props.color} strokeWidth={props.width} dot={{ fill:props.color, r: 1}} />
</LineChart>
</div>
<div className="text-center text-white/40 pb-4 -mt-2"> Time (in s) </div>
</div>
);
}
export default Chart;