From a37dd0971eb797874027ac5f16d0182111b19592 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 25 Sep 2023 22:04:19 -0700 Subject: [PATCH] set default date --- app/GraphPage.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/GraphPage.jsx b/app/GraphPage.jsx index b404da2..483f9e9 100644 --- a/app/GraphPage.jsx +++ b/app/GraphPage.jsx @@ -1,9 +1,10 @@ -import React from 'react' +import React, { useEffect } from 'react' import styled from '@emotion/styled' import { Card, Grid, TextField, Typography, Box, Container } from '@mui/material'; import { DatePicker } from '@mui/x-date-pickers'; import { LineChart, Line, XAxis, YAxis } from 'recharts'; import { useState } from 'react'; +import dayjs from 'dayjs'; const bitcoinCSV = `Date,Price 09/01/2023,26209.50 @@ -187,14 +188,21 @@ const CustomDiv = styled.div` 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 [selectedDate, setSelectedDate] = useState(); + const [selectedDate, setSelectedDate] = useState(dayjs("01/01/2014")); const json = CSVtoJSON(bitcoinCSV); const data = selectPriceDates(selectedDate, json); + return (