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 #4

Open
ThaiBinh-13 opened this issue Mar 20, 2021 · 5 comments
Open

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

ThaiBinh-13 opened this issue Mar 20, 2021 · 5 comments

Comments

@ThaiBinh-13
Copy link

Hello, I'm facing an issue that i cannot render my chart in vue3, the Error is TypeError: Cannot read property 'getContext' of undefined at Proxy.renderChart (BaseChart.tsx?b4f3:124). Which is thrown in BaseChart.tsx line 124

@mberneis
Copy link

mberneis commented Apr 3, 2021

I got a similar problem - Initial warning is

app.js:formatted:8604 [Vue warn]: Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function

and later the same getContext error because of the missing ref

Uncaught (in promise) TypeError: Cannot read property 'getContext' of undefined
    at Proxy.renderChart (app.js:formatted:103091)

@edgimopeter
Copy link

I had this error, and resolved it by removing the empty tag from my component file. It only needs the <script> portion.

This is explained in the docs for the Vue2 version: https://github.com/apertureless/vue-chartjs/

You can create your components in Vues single file components. However it is important that you do not have the included. Because Vue can't merge templates. And the template is included in the mixin. If you leave the template tag in your component, it will overwrite the one which comes from the base chart and you will have a blank screen.

@mberneis
Copy link

I switched to this fork and all seems to work pok:

    "dependencies": {
        "chart.js": "2",
        "vue-chartjs": "https://github.com/davidrunger/vue-chartjs.git#vue-3"
    }

@dalezak
Copy link

dalezak commented Jul 6, 2021

@mberneis is it required to downgrade chart.js to 2? The latest version is 3.4.1 so that's quite old.

Curious, since things were working fine and stopped, could this issue be related to a newer version of Vue?

@dalezak
Copy link

dalezak commented Jul 6, 2021

In case it helps others, I upgraded to Vue 3.1.4 which was published 2 days ago, and this error went away for me.

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

4 participants