diff options
author | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-28 13:23:13 +0530 |
---|---|---|
committer | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-28 13:23:13 +0530 |
commit | 7a431062aa79ac9c9524638e60cb4b06323ea697 (patch) | |
tree | 30bb8992d0a74d5a12faaac36fbb89c3d478edf1 /modern/src/reports | |
parent | 9c2dbcf00b944cca546875af4f0bcab695119a40 (diff) | |
download | trackermap-web-7a431062aa79ac9c9524638e60cb4b06323ea697.tar.gz trackermap-web-7a431062aa79ac9c9524638e60cb4b06323ea697.tar.bz2 trackermap-web-7a431062aa79ac9c9524638e60cb4b06323ea697.zip |
Chart report code improvements and refactoring
Diffstat (limited to 'modern/src/reports')
-rw-r--r-- | modern/src/reports/ChartReportPage.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index 19ec9c12..21c069ca 100644 --- a/modern/src/reports/ChartReportPage.js +++ b/modern/src/reports/ChartReportPage.js @@ -4,7 +4,7 @@ import ReportFilter from './ReportFilter'; import ReportLayoutPage from './ReportLayoutPage'; import { useAttributePreference } from '../common/preferences'; import { formatDate } from '../common/formatter'; -import { getConverter } from '../common/converter'; +import { speedConverter } from '../common/converter'; import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; const ReportFilterForm = ({ setItems }) => { @@ -16,17 +16,18 @@ const ReportFilterForm = ({ setItems }) => { const response = await fetch(`/api/reports/route?${query.toString()}`, { headers }); if (response.ok) { - const data = await response.json(); + const positions = await response.json(); - let formattedData = data.map(obj => { - return Object.assign( - obj, - {speed: Number(getConverter('speed')(obj.speed, speedUnit))}, - {fixTime: formatDate(obj.fixTime)} - ); + let formattedPositions = positions.map(position => { + return { + speed:Number(speedConverter(position.speed, speedUnit)), + altitude:position.altitude, + accuracy:position.accuracy, + fixTime:formatDate(position.fixTime) + } }); - setItems(formattedData); + setItems(formattedPositions); } } |