question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Please remove the <template></template> tags from your chart component

See original GitHub issue

Expected Behavior

No error

Actual Behavior

I have 3 different SFC chart components that are loaded on a page. The SFCs look almost 1:1 with the example in the documentation on using vue-chartjs in SFCs. There are no template tags in the SFCs just the script tags. When I load the view with the chart SFCs I get

Error: Please remove the <template></template> tags from your chart component. See https://vue-chartjs.org/guide/#vue-single-file-components

I’m using both the Bar and Pie charts. They still render but I get the error for each of the SFCs that are loaded.

Environment

  • vue.js version: 2.6.12
  • vue-chart.js version: 3.5.1
  • chart.js version: 2.9.4
  • npm version: 6.4.11

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
newcatcommented, Aug 12, 2022

Same here when I use a specific setup with computed properties for chartData. The reason is that the watcher for props.chartOptions is called before the onMounted callback. The watcher handler sees that the chart has not been initialized yet and therefore calls the chartCreate function, which in turn calls the renderChart function. At this point, the ref to the canvas has not been set, as the onMounted callback has also not been called. This leads to the error.

@apertureless it would be nice if you could fix it so the chartCreate or renderChart functions just fail silently if they are called before onMounted (or the watchers check, whether the component has been mounted yet and if that is not the case, they simply don’t call their respective handlers).

0reactions
gbaroncommented, Dec 1, 2022

@newcat could you please provide more information about the “specific setup with computed properties for chartData”. Ideally a codepen/repo with reproducible code. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running a simple example of vue-chartjs - Stack Overflow
So if you let the template tag in your component, it will overwrite the template defined in the base chart, that you're extending....
Read more >
Vue-chartjs error in BaseCharts.js renderChart - Get Help
I'm just a very inattentive person. In getting started guide (https://vue-chartjs.org/guide/#vue-single-file-components) mentioned “Template Tag ...
Read more >
Getting Started - vue-chartjs
Create your chart component with a data prop and options prop, so we can pass in our data and options from a container...
Read more >
Step-by-step guide - Chart.js
Step-by-step guide. Follow this guide to get familiar with all major concepts of Chart.js: chart types and elements, datasets, customization ...
Read more >
How to Create Awesome Charts in Vue 2 with Chart.js
To remove above error for invoking the app, make sure to update the ... so add the bar-chart tag inside the template directive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found