From 032d1a787384430a5bd93a3caf7e92bb0a5fa8aa Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Wed, 25 Nov 2020 14:07:59 +0530 Subject: Improvements and minor refactoring in chart report --- modern/src/reports/ChartReportPage.js | 22 +++++----------------- modern/src/reports/ReportLayoutPage.js | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 20 deletions(-) (limited to 'modern/src/reports') diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index e37f7ca..5aefca1 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 ( - - - {t('reportChartType')} - - - + ) }; @@ -58,7 +46,7 @@ const ChartReportPage = () => { const [type, setType] = useState('speed'); return ( - + diff --git a/modern/src/reports/ReportLayoutPage.js b/modern/src/reports/ReportLayoutPage.js index e4219bf..53b7039 100644 --- a/modern/src/reports/ReportLayoutPage.js +++ b/modern/src/reports/ReportLayoutPage.js @@ -1,6 +1,8 @@ import React from 'react'; -import { Grid, Paper, makeStyles } from '@material-ui/core'; +import { Grid, Paper, makeStyles, FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; import MainToolbar from '../MainToolbar'; +import { chartTypes } from '../common/chartTypes'; +import t from '../common/localization'; const useStyles = makeStyles(theme => ({ root: { @@ -16,9 +18,13 @@ const useStyles = makeStyles(theme => ({ form: { padding: theme.spacing(1, 2, 2), }, + chart: { + padding: theme.spacing(1, 2, 2), + marginTop: theme.spacing(1), + }, })); -const ReportLayoutPage = ({ reportFilterForm:ReportFilterForm, setItems, setType, children }) => { +const ReportLayoutPage = ({ reportFilterForm:ReportFilterForm, setItems, setType, showChartType, children }) => { const classes = useStyles(); return (
@@ -27,8 +33,20 @@ const ReportLayoutPage = ({ reportFilterForm:ReportFilterForm, setItems, setType - + + {showChartType && ( + + + {t('reportChartType')} + + + + )} {children} -- cgit v1.2.3