-
-
Notifications
You must be signed in to change notification settings - Fork 838
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
this.$refs doesn't seem to have expected canvas property #156
Comments
You have to remove the template part of your component. You are extending the baseChart component, which comes with a template. If you keep the <template>
<div class="app">
</div>
</template> you overwrite everything from the base chart, as templates can not be merged properly. |
Ah that makes sense! Still getting to grips with Vue 😉 Thank you very much! |
I get to this issue too, and took a while to understand what was going wrong |
Just modify the template like this , may fixed the error
|
Hey @razerraz well it is not that uncommon. If you take a look at the react community, you are mostly extending react components. However, yeah it is rather unique in vue, but in this case IMO a good fit. Beacuse vue-chartjs is only a wrapper for chartjs. Kind of a boilerplate, so you don't need to create your canvas element, set the props for the width and height, and the render methods. So while it is true, that there is some "magic" behind the components you are extending it is also the main purpose for this package. Expect the mixins there is not much code or logic behind the chart components. |
I have some ways of thinking that can not be so common in the javascript world, especialy with react community since I got sick reading 10 minutes of tutorial about it. |
Yeah I am generally not a big fan of js fake "classes". And also not a big fan of extending etc. But like I said in this case, it made sense. Yeah, the docs could need some work on this fact, as it seems confusing for some people. |
|
the error is due to |
The error ""TypeError: Cannot read property 'getContext' of undefined"" has appeared several times (see apertureless#156, apertureless#350 and a few others on StackOverflow) I think this `throw` description help devs address the issue quickly.
Expected Behavior
Expect the example chart to render in the browser.
Actual Behavior
Error in console and nothing renders to the page.
Error occurs in the Bar
[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'getContext' of undefined"
My Vue Component
Environment
The text was updated successfully, but these errors were encountered: