Error: Please remove the <template></template> tags from your chart component
See original GitHub issueExpected 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:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here when I use a specific setup with computed properties for
chartData
. The reason is that the watcher forprops.chartOptions
is called before theonMounted
callback. The watcher handler sees that the chart has not been initialized yet and therefore calls thechartCreate
function, which in turn calls therenderChart
function. At this point, the ref to the canvas has not been set, as theonMounted
callback has also not been called. This leads to the error.@apertureless it would be nice if you could fix it so the
chartCreate
orrenderChart
functions just fail silently if they are called beforeonMounted
(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).@newcat could you please provide more information about the “specific setup with computed properties for chartData”. Ideally a codepen/repo with reproducible code. Thanks