set default date

developement
Max 2023-09-25 22:04:19 -07:00
parent e2c3ea43c4
commit a37dd0971e
1 changed files with 10 additions and 2 deletions

View File

@ -1,9 +1,10 @@
import React from 'react' import React, { useEffect } from 'react'
import styled from '@emotion/styled' import styled from '@emotion/styled'
import { Card, Grid, TextField, Typography, Box, Container } from '@mui/material'; import { Card, Grid, TextField, Typography, Box, Container } from '@mui/material';
import { DatePicker } from '@mui/x-date-pickers'; import { DatePicker } from '@mui/x-date-pickers';
import { LineChart, Line, XAxis, YAxis } from 'recharts'; import { LineChart, Line, XAxis, YAxis } from 'recharts';
import { useState } from 'react'; import { useState } from 'react';
import dayjs from 'dayjs';
const bitcoinCSV = `Date,Price const bitcoinCSV = `Date,Price
09/01/2023,26209.50 09/01/2023,26209.50
@ -187,14 +188,21 @@ const CustomDiv = styled.div`
width: 100% width: 100%
`; `;
function formatDate(date) {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0'); // January is 0!
const year = date.getFullYear();
return month + '/' + day + '/' + year;
}
const GraphPage = () => { const GraphPage = () => {
const [selectedDate, setSelectedDate] = useState(); const [selectedDate, setSelectedDate] = useState(dayjs("01/01/2014"));
const json = CSVtoJSON(bitcoinCSV); const json = CSVtoJSON(bitcoinCSV);
const data = selectPriceDates(selectedDate, json); const data = selectPriceDates(selectedDate, json);
return ( return (
<CustomDiv> <CustomDiv>
<Container> <Container>