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

destroy() not defined if config isn't given to Chart on construction #2526

Closed
sknick opened this issue May 12, 2016 · 2 comments
Closed

destroy() not defined if config isn't given to Chart on construction #2526

sknick opened this issue May 12, 2016 · 2 comments

Comments

@sknick
Copy link

sknick commented May 12, 2016

I have discovered that the destroy() method of the Chart object isn't being added to the object prototype if the second "config" parameter to the Chart constructor isn't defined. While the documentation indeed doesn't indicate that the config parameter is optional, the library also doesn't otherwise obviously fail when you don't pass it--you just can't invoke destroy(). My workaround is to pass this minimal config object:

{
    data:
    {
        datasets: []
    }
}

I believe the fact that a controller is never hooked up if config isn't passed is the root cause:

if (config) {
    this.controller = new Chart.Controller(this);
}
@etimberg
Copy link
Member

@sknick I was thinking more about this. I believe that the reason for not going further if there is a config is that you won't know what type of chart to create. Maybe we can bail out earlier in this case and not do anything

@sknick
Copy link
Author

sknick commented May 13, 2016

Ya, either bail or assume a default. I think "bar" is normally inferred by default when a config is given without a type, right? You could use that as a default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants