Skip to content

Add real weather forecast visualizations using OpenWeatherMap forecast API#178

Open
awrya-cmd wants to merge 4 commits into
thetechguardians:mainfrom
awrya-cmd:feature/weather-trend-charts
Open

Add real weather forecast visualizations using OpenWeatherMap forecast API#178
awrya-cmd wants to merge 4 commits into
thetechguardians:mainfrom
awrya-cmd:feature/weather-trend-charts

Conversation

@awrya-cmd

@awrya-cmd awrya-cmd commented Jun 9, 2026

Copy link
Copy Markdown

Add Real Weather Forecast Visualizations to Analysis Page

Overview

This PR adds weather forecast visualizations to the Analysis page using real forecast data from the OpenWeatherMap 5-Day / 3-Hour Forecast API.

Unlike the initial approach of generating trend data from a single weather snapshot, this implementation uses only actual forecast values returned by the API. No synthetic, estimated, simulated, or fabricated weather data is displayed.

Changes Made

Backend

Modified: backend/alertsystem.py

  • Added a fetch_forecast() helper to retrieve forecast data from the OpenWeatherMap Forecast API.
  • Integrated forecast fetching into the /weather endpoint.
  • Included forecast information in the API response payload.
  • Added graceful error handling for forecast API failures.

Frontend

Analysis Page

Modified: Frontend/Analysis/analysis.html

  • Added a dedicated Weather Trends section.

  • Integrated Chart.js via CDN.

  • Added chart containers for:

    • Temperature Trends
    • Humidity Trends
    • Rainfall Trends

Styling

Modified: Frontend/Analysis/analysis.css

  • Added responsive layouts for trend visualizations.
  • Styled chart containers to match the existing dark glassmorphism design.
  • Added empty-state styling for unavailable forecast data.
  • Added mobile-friendly stacking behavior.

Chart Rendering

Modified: Frontend/Analysis/analysis.js

  • Removed all synthetic trend generation logic.

  • Implemented parsing of real forecast data from the API response.

  • Added dynamic Chart.js rendering for:

    • Temperature (Line Chart)
    • Humidity (Line Chart)
    • Rainfall (Bar Chart)
  • Added chart instance cleanup to prevent duplicate overlays.

  • Added fallback handling when forecast data is unavailable.

  • Uses real forecast timestamps formatted into readable labels (e.g. "Tue 12 PM", "Wed 12 AM").

Data Accuracy

  • All chart values originate directly from OpenWeatherMap forecast responses.
  • No generated, estimated, or mock weather values are used.
  • If forecast data is unavailable, users see a clear fallback message instead of misleading visualizations.

Testing

Verified

  • Backend forecast API integration returns forecast datasets successfully.
  • Charts render automatically after weather analysis is completed.
  • Charts update correctly when a new location is searched.
  • Existing analysis functionality remains unaffected.
  • Responsive layouts work correctly on smaller screens.
  • Empty-state handling works when forecast data is unavailable.

Screenshots

image

Issue #35

@awrya-cmd awrya-cmd changed the title Added weather visualization support Add real weather forecast visualizations using OpenWeatherMap forecast API Jun 9, 2026
@Vikrant0207

Copy link
Copy Markdown
Collaborator

@awrya-cmd resolve conflicts

@awrya-cmd

Copy link
Copy Markdown
Author

@awrya-cmd resolve conflicts

resolved all.

@Vikrant0207

Copy link
Copy Markdown
Collaborator

@awrya-cmd
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants