Chartjs-Meteor / React.js / Chart.js issue

0👍

You actually had it correct your original way,

var ctx = document.getElementById("myChart");

The reason for the jquery errors is because you left off the # sign (needed since you are dealing with an id). This would work though.

$("#myChart")

However, I think you will still get an error. I think the problem is that your canvas element is not actually rendered yet since you are calling {this.drawChart()} directly from the render function.

I don’t know a lot about react, but can you call this function after you have rendered? I do however know a lot about chart.js and this error pops up when canvas is not yet in the dom but you try to access it.

Leave a comment