carlcraig / tc-angular-chartjs

AngularJS directives for Chart.js
http://carlcraig.github.io/tc-angular-chartjs/
Other
233 stars 83 forks source link

How to do I make chart change its size when containing <div> changes? #18

Closed vic64 closed 9 years ago

vic64 commented 9 years ago

Currently - if I change the div's size nothing happens. It only redraws if I change the browser window size...

carlcraig commented 9 years ago

Ok, for this, double check you are using the latest Chart.js vendor (tc-chartjs will need Chart.js 1.0.0^ not the 0.2 version). You will also need to make sure that responsive: true, is in your chart options. check http://carlcraig.github.io/tc-angular-chartjs/doughnut/ as the chart there will resize when the div changes size.

vic64 commented 9 years ago

I'm on 1.0.1-beta4. It's responsive.

I'm making DIV size change via CSS (dynamically assigning via ng-class).

carlcraig commented 9 years ago

ok, if you have access to the chart object via chart="variable" directive, then you can call .resize() on that object to force the chart to resize.

carlcraig commented 9 years ago

@vic64 did you manage to solve this issue? If its solved feel free to close the issue.