-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Size of chart isn't constrained by canvas element #3023
Comments
Same problem here. The only solution I found is to constrain the width of the parent element. |
You need to set See here: http://www.chartjs.org/docs/#chart-configuration-common-chart-configuration |
According to the docs: Resizes when the canvas container does. To me, that doesn't imply "I will get bigger than then canvas". Does it imply that to you? I could be reading it wrong. |
It references the canvas container, not the canvas itself - meaning the parent. if your container (a div holding the canvas) constrains the canvas, then it'll only expand to that parent. To be clear, the canvas is resized by Chart.js (if |
Ah - so if my canvas is 'naked' on the page, ie right under body.... ok. This makes sense. Maybe the docs could make this is a bit clearer though - for slow folks like me? (And obviously I wasn't the only person to run into this.) |
What do you mean? To make field description description clearer, or the behaviour and usage explanations more accessible? For the former, the field description could be changed to For the latter, I don't know... Maybe adding a sample html file? This would need input from the project devs. |
Maybe the initial sample could include a div with a set size. I'd kind of imagine most people would not want a full screen chart. Not that it wouldn't make sense sometimes of course, but in general, I'd assume a set size. |
Will add to my coming doc updates |
Adds a lot of new information to the docs that will help developers better utilize the entire Chart.js library List of implemented changes: - Reverse option for legends (resolves chartjs#3102) - Information about chart resizing (resolves chartjs#3023) - Mixed chart types (resolves chartjs#2825) (resolves chartjs#2431) - Chart library comparison table (resolves chartjs#2605) - getDetasetMeta function information (resolves chartjs#2521) - Popular Extensions (resolves chartjs#2365)
I'm using the default chart from the docs (http://www.chartjs.org/docs/#getting-started-creating-a-chart) and I've noticed that even though my canvas has a width and height of 400, the chart takes over the entire browser, it actually goes below the fold. I feel like something this wrong must be a dumb mistake on my part (grin), so what am I missing?
The text was updated successfully, but these errors were encountered: