aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/components/Graph.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-08 13:16:57 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-08 13:16:57 -0700
commit2cd374bb9fa941d7e2a6fd8aa5079893a158c98f (patch)
treef4ee48130592fed5de25dce7af4ac0cbeb017680 /modern/src/reports/components/Graph.js
parent2352071211b61c10fa5bf5736baaff7809d18bf0 (diff)
downloadtrackermap-web-2cd374bb9fa941d7e2a6fd8aa5079893a158c98f.tar.gz
trackermap-web-2cd374bb9fa941d7e2a6fd8aa5079893a158c98f.tar.bz2
trackermap-web-2cd374bb9fa941d7e2a6fd8aa5079893a158c98f.zip
Reorganize remaining files
Diffstat (limited to 'modern/src/reports/components/Graph.js')
-rw-r--r--modern/src/reports/components/Graph.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/modern/src/reports/components/Graph.js b/modern/src/reports/components/Graph.js
new file mode 100644
index 00000000..63d24eee
--- /dev/null
+++ b/modern/src/reports/components/Graph.js
@@ -0,0 +1,33 @@
+import React from 'react';
+import { withWidth } from '@material-ui/core';
+import {
+ LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer,
+} from 'recharts';
+
+const CustomizedAxisTick = ({ x, y, payload }) => {
+ 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 }) => (
+ <ResponsiveContainer height={400} width="100%" debounce={1}>
+ <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 withWidth()(Graph);