blob: b785e06f22debac85f680b60367a9810c14ef01e (
plain)
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
32
33
34
35
|
import React from 'react';
import { Box, Paper } from '@material-ui/core';
import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
const CustomizedAxisTick = ({ x, y, payload }) =>{
console.log('inside customized tick ', payload.value)
if(!payload.value) {
return payload.value;
}
const parts = payload.value.split(' ');
return (
<g transform={`translate(${x},${y})`}>
<text x={0} y={0} dy={16} textAnchor="end" fill="#666" transform="rotate(-35)">{parts[0]}</text>
<text x={0} y={16} dy={16} textAnchor="end" fill="#666" transform="rotate(-35)">{parts[1]}</text>
</g>
);
}
const Graph = ({ type, items }) => {
return (
<ResponsiveContainer height={400} width={500}>
<LineChart data={items}>
<XAxis dataKey="fixTime" tick={<CustomizedAxisTick/>} height={60} />
<YAxis />
<CartesianGrid strokeDasharray="3 3" />
<Tooltip />
<Legend />
<Line type="natural" dataKey={type} />
</LineChart>
</ResponsiveContainer>
);
}
export default Graph;
|