(WARNING: THIS IS OUTDATED, DON'T USE AS IS! INSTEAD CHECK OUT THE COMMENTS AT THE BOTTOM)
And check out: https://github.com/nuxt/nuxt.js/tree/dev/examples/vue-chartjs
How does this work
- Create a custom plugin and put it in
plugins
(plugins_vue-chartjs.js). - Add the plugin to
nuxt.config.js
and setssr
tofalse
to prevent the server to initialize it. - You can use the component now just like other Vue-components. The only problem is that you get errors because the DOM-tree is out of sync (because the server misses the component)
- As
mounted()
is only called by the client (browser) we're using this to render the component only in the browser. AddshowLine: false
to data (so the server will not render it) and turn it totrue
inmounted()
. - Use
v-if
to render the component. Now it won't be rendered on the server side, but it will show up in de browser.
This way also works with other Vue.js plugins
Used in this example:
npm install vue-chartjs --save
npm install chart.js --save
This was very helpful, cheers