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

TypeError: Cannot read property 'getContext' of undefined #627

Closed
felix2056 opened this issue Jul 2, 2020 · 4 comments
Closed

TypeError: Cannot read property 'getContext' of undefined #627

felix2056 opened this issue Jul 2, 2020 · 4 comments

Comments

@felix2056
Copy link

felix2056 commented Jul 2, 2020

Expected Behavior

Chart should display

Actual Behavior

Chart doesn't display

Environment

  • vue.js version: <2.2>
  • vue-chart.js version:
  • npm version: <6.13.4>
@johngoben-righteye
Copy link

johngoben-righteye commented Jul 8, 2020

The problem is probably that you have a template tag. See #156.

@apertureless
Copy link
Owner

Let me check my 🔮 .
Please provide a reproduction.

@ramey29
Copy link

ramey29 commented Jul 16, 2020

the error is due to this.$refs.canvas.getContext('2d') in BaseCharts.js , hence you can just add reference for the canvas object by adding below line to your template <canvas ref="canvas"></canvas>
and it shall work or remove <template></template> tag

@apertureless
Copy link
Owner

There is no need to add any canvas to your template, because thats the actual problem.
If you have even an empty <template> tag in your SFC with your chart, the template content of the base chart will be overwritten, hence the canvas element will be deleted.

Removing the template tag is the proper fix.

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

4 participants