I seem to be having trouble accessing this function properly due to an error. I am unsure of how to troubleshoot this issue and determine the correct solution. Any guidance would be greatly appreciated.
The component PerformanceDonut.vue
is located within the Page.vue
file.
Here's the code snippet from PerformanceDonut.vue
:
// ...
methods: {
drawGraph() {
this.chart = new CanvasJS.Chart(this.chartName, this.chartOptions);
this.chart.render();
console.log('Donut drawn')
}
},
mounted() {
this.drawGraph();
// The function gets executed here
// Re-draw graph for print preview
window.matchMedia('print').addListener(function(mql) {
if (mql.matches) {
this.drawGraph();
// Error occurs here
}
});
}
Console displays the following error message:
Uncaught TypeError: this.drawGraph is not a function