From df01e1d751980843506946a194fa9f67489182b1 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Fri, 20 Nov 2020 13:56:14 +0530 Subject: Implementing chart report initial structure --- modern/src/reports/ChartReportPage.js | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 modern/src/reports/ChartReportPage.js (limited to 'modern/src/reports/ChartReportPage.js') diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js new file mode 100644 index 0000000..6898933 --- /dev/null +++ b/modern/src/reports/ChartReportPage.js @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; +import { Card, CardHeader, CardContent } from '@material-ui/core'; +import { Box, Divider } from '@material-ui/core'; +import { makeStyles } from '@material-ui/core/styles'; +import ReportFilter from './ReportFilter'; +import ReportLayoutPage from './ReportLayoutPage'; +import ChartType from './ChartType'; + +import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; + +const useStyles = makeStyles((theme) => ({ + formControl: { + minWidth: 160, + }, +})); + +const ReportFilterForm = ({ setItems }) => { + + const handleSubmit = async (deviceId, from, to, mail, headers) => { + const query = new URLSearchParams({ deviceId, from, to, mail }); + const response = await fetch(`/api/reports/route?${query.toString()}`, { headers }); + if (response.ok) { + const contentType = response.headers.get('content-type'); + if (contentType) { + if (contentType === 'application/json') { + setItems(await response.json()); + } else { + window.location.assign(window.URL.createObjectURL(await response.blob())); + } + } + } + }; + + return ; +}; + +const CustomizedAxisTick = ({ x, y, stroke, payload }) =>{ + return ( + + {payload.value} + + ); +} + +const ChartReportPage = () => { + + const [items, setItems] = useState([]); + const [type, setType] = useState('speed'); + + return ( + + + } /> + + + + + + } /> + + + + + + + + + + + + ); +} + +export default ChartReportPage; -- cgit v1.2.3