Fix Chart.js resize for charts in hidden tab panels#81
Merged
Conversation
Charts created in hidden tab panels (display:none) have zero dimensions. When a tab is activated, use requestAnimationFrame + Chart.getChart().resize() to ensure charts render at correct dimensions after layout reflow. https://claude.ai/code/session_01JMApLxRnxbdgtrCjcQwFTH
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.
Summary
This PR fixes an issue where Chart.js charts created in hidden tab panels were not properly resizing when their containing tab became visible. The fix ensures charts are resized after the DOM layout reflow occurs when switching tabs.
Changes
requestAnimationFramecallback to the tab switching function that triggers Chart.js resize for all canvas elements in the newly visible panelImplementation Details
When a tab panel transitions from hidden to visible, Chart.js charts within that panel need to be explicitly resized since they were rendered while their container had
display: noneor similar hidden state. The fix:requestAnimationFrameto ensure the layout has reflowedresize()method if it existsThis ensures charts display with correct dimensions immediately after tab activation.
https://claude.ai/code/session_01JMApLxRnxbdgtrCjcQwFTH