diff options
author | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-25 14:07:59 +0530 |
---|---|---|
committer | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-25 14:07:59 +0530 |
commit | 032d1a787384430a5bd93a3caf7e92bb0a5fa8aa (patch) | |
tree | 87a3fc0b466b37108c8f5c6a4a0a6787fa8293fb /modern/src/reports/ChartReportPage.js | |
parent | 34ec9a62ac0b65665f15f6e80729495e2558547f (diff) | |
download | trackermap-web-032d1a787384430a5bd93a3caf7e92bb0a5fa8aa.tar.gz trackermap-web-032d1a787384430a5bd93a3caf7e92bb0a5fa8aa.tar.bz2 trackermap-web-032d1a787384430a5bd93a3caf7e92bb0a5fa8aa.zip |
Improvements and minor refactoring in chart report
Diffstat (limited to 'modern/src/reports/ChartReportPage.js')
-rw-r--r-- | modern/src/reports/ChartReportPage.js | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index e37f7ca1..5aefca15 100644 --- a/modern/src/reports/ChartReportPage.js +++ b/modern/src/reports/ChartReportPage.js @@ -1,15 +1,12 @@ import React, { useState } from 'react'; -import { Box, Paper, FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; +import { Box, Paper } from '@material-ui/core'; import ReportFilter from './ReportFilter'; import ReportLayoutPage from './ReportLayoutPage'; -import t from '../common/localization'; -import { chartTypes } from '../common/chartTypes'; import { useAttributePreference } from '../common/preferences'; import { getConverter, formatDate } from '../common/formatter'; - import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; -const ReportFilterForm = ({ setItems, setType }) => { +const ReportFilterForm = ({ setItems }) => { const speedUnit = useAttributePreference('speedUnit'); @@ -20,7 +17,7 @@ const ReportFilterForm = ({ setItems, setType }) => { const data = await response.json(); let formattedData = data.map((obj)=>{ return Object.assign(obj, - {speed: getConverter('speed')(obj.speed, speedUnit)}, + {speed: Number(getConverter('speed')(obj.speed, speedUnit))}, {fixTime: formatDate(obj.fixTime)} ); }) @@ -29,16 +26,7 @@ const ReportFilterForm = ({ setItems, setType }) => { } return ( - <ReportFilter handleSubmit={handleSubmit} showOnly > - <FormControl variant="filled" margin="normal" fullWidth> - <InputLabel>{t('reportChartType')}</InputLabel> - <Select defaultValue="speed" onChange={e => setType(e.target.value)}> - {chartTypes.map(item => ( - <MenuItem key={item.id} value={item.id}>{item.name}</MenuItem> - ))} - </Select> - </FormControl> - </ReportFilter> + <ReportFilter handleSubmit={handleSubmit} showOnly /> ) }; @@ -58,7 +46,7 @@ const ChartReportPage = () => { const [type, setType] = useState('speed'); return ( - <ReportLayoutPage reportFilterForm={ReportFilterForm} setItems={setItems} setType={setType}> + <ReportLayoutPage reportFilterForm={ReportFilterForm} setItems={setItems} setType={setType} showChartType> <Paper> <Box height={400}> <ResponsiveContainer> |