0👍
Chart.js requires a <canvas>
element at initialization. You seem to have known this at some point as you have the right code, but it’s commented out and replaced with a string:
var ctx = 'testChart';
//var ctx = document.getElementById('testChart');
Simply reverse these to make it work:
//var ctx = 'testChart';
var ctx = document.getElementById('testChart');
Of course, you’ll need to ensure the <canvas>
element is present in the DOM at runtime.
- Chartjs-I want to use an object to help create a chart with Chartjs
- Chartjs-Angular protractor tests timeout on pages containing Chart.js
Source:stackexchange.com