[Chartjs]-Chart.js uncaught reference error while updating

1👍

the chart needs to be declared outside of the function –> drawBarChart
in order to be accessed from another function –> update

like this…

// add declaration here
var myChart;

function drawBarChart() {

console.log("drawing bar . . .");


var myCanvas = document.getElementById("myCanvas");

var ctx = myCanvas.getContext('2d');

// remove var here
myChart = new Chart(ctx, {

...

Leave a comment