diff --git a/package.json b/package.json index d527454..9a0dd53 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,12 @@ "preview": "vite preview" }, "dependencies": { + "leaflet": "^1.9.4", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-leaflet": "^4.2.1", "react-router-dom": "^6.27.0", - "leaflet": "^1.9.4", - "react-leaflet": "^4.2.1" + "recharts": "^3.2.1" }, "devDependencies": { "@vitejs/plugin-react": "^4.3.1", diff --git a/src/pages/Weather.jsx b/src/pages/Weather.jsx index 6a68d52..ebf451a 100644 --- a/src/pages/Weather.jsx +++ b/src/pages/Weather.jsx @@ -15,7 +15,7 @@ * - [x] Add error retry button component * - [ ] Add favorites list (pin cities) * Advanced: - * - [ ] Hourly forecast visualization (line / area chart) + * - [x] Hourly forecast visualization (line / area chart) * - [x] Animate background transitions * - [ ] Add geolocation: auto-detect user city (with permission) */ @@ -30,6 +30,17 @@ import { clearWeatherCache, getCacheStats, } from "../services/weather.js"; +import { + LineChart, + Line, + XAxis, + YAxis, + Tooltip, + ResponsiveContainer, + CartesianGrid, + AreaChart, + Area, +} from "recharts"; // Helper to determine weather background class const weatherToClass = (desc = "") => { @@ -65,7 +76,10 @@ function renderWeatherAnimation(variant) { <>
@@ -290,36 +310,25 @@ export default function Weather() {
{/* 3-Day Forecast */}
{forecast.map((day, i) => {
- const condition =
- day.hourly?.[0]?.weatherDesc?.[0]?.value || "Clear";
+ const condition = day.hourly?.[0]?.weatherDesc?.[0]?.value || "Clear";
const badge = getBadgeStyle(condition);
return (
- (e.currentTarget.style.display = "none")
- }
- />
-
(e.currentTarget.style.display = "none")}
+ />
+