aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/ChartReportPage.js
diff options
context:
space:
mode:
authorAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-27 16:31:49 +0530
committerAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-27 16:31:49 +0530
commit9c2dbcf00b944cca546875af4f0bcab695119a40 (patch)
treea6ff401d8ccd615abfd9166f1d45a5626c479ac1 /modern/src/reports/ChartReportPage.js
parent032d1a787384430a5bd93a3caf7e92bb0a5fa8aa (diff)
downloadtrackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.tar.gz
trackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.tar.bz2
trackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.zip
Chart report code improvements and refactoring
Diffstat (limited to 'modern/src/reports/ChartReportPage.js')
-rw-r--r--modern/src/reports/ChartReportPage.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js
index 5aefca15..19ec9c12 100644
--- a/modern/src/reports/ChartReportPage.js
+++ b/modern/src/reports/ChartReportPage.js
@@ -3,7 +3,8 @@ import { Box, Paper } from '@material-ui/core';
import ReportFilter from './ReportFilter';
import ReportLayoutPage from './ReportLayoutPage';
import { useAttributePreference } from '../common/preferences';
-import { getConverter, formatDate } from '../common/formatter';
+import { formatDate } from '../common/formatter';
+import { getConverter } from '../common/converter';
import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
const ReportFilterForm = ({ setItems }) => {
@@ -14,13 +15,17 @@ const ReportFilterForm = ({ setItems }) => {
const query = new URLSearchParams({ deviceId, from, to, mail });
const response = await fetch(`/api/reports/route?${query.toString()}`, { headers });
if (response.ok) {
+
const data = await response.json();
- let formattedData = data.map((obj)=>{
- return Object.assign(obj,
- {speed: Number(getConverter('speed')(obj.speed, speedUnit))},
- {fixTime: formatDate(obj.fixTime)}
- );
- })
+
+ let formattedData = data.map(obj => {
+ return Object.assign(
+ obj,
+ {speed: Number(getConverter('speed')(obj.speed, speedUnit))},
+ {fixTime: formatDate(obj.fixTime)}
+ );
+ });
+
setItems(formattedData);
}
}
@@ -46,7 +51,7 @@ const ChartReportPage = () => {
const [type, setType] = useState('speed');
return (
- <ReportLayoutPage reportFilterForm={ReportFilterForm} setItems={setItems} setType={setType} showChartType>
+ <ReportLayoutPage reportFilterForm={ReportFilterForm} setItems={setItems} type={type} setType={setType} showChartType>
<Paper>
<Box height={400}>
<ResponsiveContainer>