I know I'm not accessing this function correct by the error, but I'm not sure how to debug this and determine the correct approach. Guidance is appreciated.
PerformanceDonut.vue is a component in Page.vue
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 executes here
// Redraw graph on print preview
window.matchMedia('print').addListener(function(mql) {
if (mql.matches) {
this.drawGraph();
// Error here
}
});
}
Console Error:
Uncaught TypeError: this.drawGraph is not a function