Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resize problems when charts are initially hidden #1467

Merged
merged 10 commits into from
Sep 19, 2015

Conversation

etimberg
Copy link
Member

This commit aims to fix the resize problems for charts documented in #592 #762 #961 #1020 #1311 and #1395
It also possibly also fixes #1006 but this has not been tested.

New Dependency

Cloned javascript-detect-element-resize into the chart.js organization. Use this to detect when an individual canvas element resizes. This removes the need for the core.responsive file and so it is removed.

Aspect Ratios

Charts can now force an aspect ratio if the user does not specify the original canvas size. This will make the doughnut canvas square for instance if the user does not give it a size.

Canvas Size

Using the gist from #1395, the max-width property of the parent container should now be obeyed. destroy no longer changes the canvas style width and height properties.

Category Scale

Fixed a size issues caused by the category scale that caused the chart to not take up the entire canvas when the labels may have needed to rotate.

Doughnut and Polar Area Charts

Ensure that internal innerRadius and outerRadius properties are always >= 0 even when the canvas has no size (ie is display: none). This prevents crashes.

Samples

Updated the bar sample to hide the chart with a display: none style. Use the 'show' button to show the canvas container which triggers a resize.

@etimberg
Copy link
Member Author

@tannerlinsley @derekperkins please give this a good look over

@tannerlinsley
Copy link
Contributor

Amazing work! Merging.

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