import { Group, Select, Stack } from '@mantine/core'; import { useState } from 'react'; import { Area, AreaChart, CartesianGrid, ComposedChart, Legend, Line, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { selectClasses } from 'styles'; import WeatherTooltip from './WeatherTooltip'; export default function WeatherGraphs({ hourly, formatted, }: { hourly: any; formatted?: boolean; }) { const colorPrecipitation = 'colorPrecipitation'; const colorHumidity = 'colorHumidity'; const [timeFrame, setTimeFrame] = useState(24); const later = new Date(); const now = new Date(); later.setTime(now.getTime() + timeFrame * 60 * 60 * 1000); const hourlyForecast = formatted ? hourly : hourly?.time ?.map((_: any, index: number) => { return { dewpoint: hourly.dew_point_2m?.[index].toFixed(0), isDaytime: hourly.is_day?.[index], name: hourly.time[index].toLocaleString('en-us'), startTime: hourly.time[index], endTime: hourly.time[index + 1], probabilityOfPrecipitation: hourly.precipitation_probability?.[index], temperature: hourly.temperature_2m?.[index].toFixed(0), apparentTemperature: hourly.apparent_temperature?.[index].toFixed(0), relativeHumidity: hourly.relative_humidity_2m?.[index].toFixed(0), }; }) .filter((hour: any) => hour.startTime > now && hour.startTime < later); return ( {!formatted && (