Skip to content

fix(stats): Statistics page charts grow unbounded when detection data exists - #39

Merged
cport1 merged 1 commit into
mainfrom
fix/stats-chart-height
Jul 23, 2026
Merged

cport1 merged 1 commit into
mainfrom
fix/stats-chart-height

Conversation

@cport1

@cport1 cport1 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

The three Chart.js canvases on the Statistics page use responsive: true + maintainAspectRatio: false with no height-constrained parent. Chart.js sizes the canvas from its container, the container's height follows the canvas, and the resize observer loops — the canvas grows to ~25,000px tall and the trend chart is unusable.

This ships in 2.2.3 on WordPress.org. It was never caught in review because with an empty detections table the charts are never instantiated (labels.length > 0 guards) — it appears the moment a site records real detections, i.e. for exactly the users the page is for.

Fix

Standard Chart.js pattern: wrap each canvas in .webdecoy-chart-box (position: relative; height: 300px) and drop the ignored height attributes.

Verification

Reproduced and verified in a local WP 7.0.2 install with 380+ seeded detections: before, canvases reached 24,882px; after, stable at 300px with all three charts rendering correctly (the wp.org listing screenshots were captured from this build).

Suggest releasing as 2.2.4 to wp.org since 2.2.3 users hit this on their first visit to Statistics.

Chart.js with responsive:true + maintainAspectRatio:false requires a
positioned, fixed-height parent. Without one the canvas enters a resize
feedback loop and grows unbounded (~25000px tall) as soon as the
Statistics page has any detection data. Never seen in review because an
empty detections table skips chart instantiation entirely.

Wrap each canvas in .webdecoy-chart-box (position:relative; height:300px)
and drop the ignored height attributes.
@cport1
cport1 merged commit 764c300 into main Jul 23, 2026
3 checks passed
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.

1 participant