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

Directives need to destroy chart when directive is destroyed #68

Open
speshy opened this issue Feb 24, 2015 · 1 comment
Open

Directives need to destroy chart when directive is destroyed #68

speshy opened this issue Feb 24, 2015 · 1 comment

Comments

@speshy
Copy link

speshy commented Feb 24, 2015

We're using ng-view in our application. Navigating to and from a view with a chart and a view without a chart I found two things happening:

  • When moving from chart to non-chart, the non-chart view throws rendering errors when the browser window resizes (Chart js registers an event handler for window resize, and loops through instances to redraw them).
  • The number of instances in Chart.instances increases each time the user navigates to the view containing a chart, it never decreases when user navigates away from the chart view.

The following is needed in the link function:

$scope.$on("$destroy", function(){
    if (chartCreated){
        chartCreated.destroy();
    }
});
@LeleDev
Copy link

LeleDev commented Jun 15, 2015

+1

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

No branches or pull requests

2 participants