0๐
Youโre probably not able to get a hold of ctx
.
Inspect with the console like this:
var ctx = document.getElementById("currenciesTag").getContext("2d");
console.log(ctx);
Check your html and make sure you have, for example:
<body>
<canvas id="currenciesTag" width="600" height="400"></canvas>
</body>
You can see your code working here:
0๐
I had same problem and it takes 4.5 hours to solve it god damn nevermind if you have
window.onload = function() { }
outside of your
var ctx = document.getElementById('canvas').getContext('2d');
code just delete it after that you can use it in any function like $(function() { }); or button click. Have a nice day ๐
- Chartjs-Is It Possible To Generate a ChartJS In C# Web API And Save Image?
- Chartjs-How to use chartjs-plugin-trendline with react-chartjs-2
Source:stackexchange.com