Skip to content

Comments

fix: implement hard limit for canvas width when using forecast mode#48

Merged
troinine merged 4 commits intomainfrom
bugfix/canvas-overflow-on-firefox
Dec 31, 2025
Merged

fix: implement hard limit for canvas width when using forecast mode#48
troinine merged 4 commits intomainfrom
bugfix/canvas-overflow-on-firefox

Conversation

@troinine
Copy link
Owner

Fixes #40

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a hard limit on canvas width to prevent rendering errors when displaying large forecast datasets in chart mode. The implementation addresses browser canvas size limitations by truncating forecast data to fit within a 16384-pixel width constraint.

Key Changes:

  • Introduces a MAX_CANVAS_WIDTH constant (16384px) and a safeForecast getter that truncates forecast data when necessary
  • Updates all chart-related methods to use the truncated forecast data instead of the raw forecast property
  • Adds comprehensive test coverage for the truncation logic with a 500-item forecast scenario

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/components/wfc-forecast-chart.ts Implements canvas width limiting by adding MAX_CANVAS_WIDTH constant, safeForecast getter with gap-aware calculation, and updates render/chart methods to use truncated data
test/weather-forecast-chart.test.ts Adds test case verifying 500-item forecast is correctly truncated to 327 items based on itemWidth=50 and gap=0
README.md Documents the 16384px canvas width limitation and explains that forecast data exceeding this limit will be truncated

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

troinine and others added 3 commits December 31, 2025 21:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tero Roininen <troinine@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tero Roininen <troinine@users.noreply.github.com>
@troinine troinine added the fix Fix or improvement label Dec 31, 2025
@troinine troinine merged commit e5336f4 into main Dec 31, 2025
3 checks passed
@troinine troinine deleted the bugfix/canvas-overflow-on-firefox branch December 31, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fix or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hourly forecas issue on PC in firefox - Canvas exceeds max size

1 participant