You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The chart will still render without client-only however the client side DOM tree will no longer match the server render and a console error will be shown.
Multi chart example
You can add multiple Chart.js types to your chart.js plugin file like so:
import Vue from 'vue'
import { Line } from 'vue-chartjs'
import { Pie } from 'vue-chartjs'
Vue.component('line-chart', {
extends: Line,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
Vue.component('pie-chart', {
extends: Pie,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
This worked well for me with everyone's tips. I had to remove <client-only>...</client-only> .. it was causing some screwy page rendering behavior. My charts were showing up only after saving my Nuxt project, but not on a page refresh. Removing that resolved the issue for me and I haven't noticed any problems or console errors without it
I'm using chartsjs in markdown files with embedded Vue components.
I'm getting this error:
ERROR in ./node_modules/vue-chartjs/dist/index.js 216:37
Module parse failed: Unexpected token (216:37)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const ref = shallowRef(null);
| const reforwardRef = (chartRef)=>{
I'm getting this error: ERROR in ./node_modules/vue-chartjs/dist/index.js 216:37 Module parse failed: Unexpected token (216:37) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | const ref = shallowRef(null); | const reforwardRef = (chartRef)=>{
ref.value = chartRef?.chart;
| }; | expose({
package.json
"nuxt": "^2.15.8", "vue": "^2.7.10",
you have to use this versions
{
...
"dependencies": {
"chart.js": "2.9.4",
"vue-chartjs": "^3.5.1"
}
...
}
This worked well for me with everyone's tips. I had to remove
<client-only>...</client-only>
.. it was causing some screwy page rendering behavior. My charts were showing up only after saving my Nuxt project, but not on a page refresh. Removing that resolved the issue for me and I haven't noticed any problems or console errors without itI'm using chartsjs in markdown files with embedded Vue components.
Thank you all for your input on this.
Below is what worked for me.
Relevant package versions:
/plugins/chart.js
nuxt.config.js
markdown file: (I'm doing some custom work here.. so the format will look a bit off)
Custom component: