fix(stats): Statistics page charts grow unbounded when detection data exists - #39
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The three Chart.js canvases on the Statistics page use
responsive: true+maintainAspectRatio: falsewith 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 > 0guards) — 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 ignoredheightattributes.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.