7๐
โ
the problem is this line:
var ctx = document.getElementById('sexe');
you do not have any element with id โsexeโ on the page
0๐
The error was due to the element not being present in the HTML when Chart.js was trying to attach the chart on it.
0๐
If u are using Angular 2+, try to build the options and data chart in. I needed to do this because I used an @Input() attribute to get the data shown in the chart:
ngOnChanges(changes: SimpleChanges){
this.options = {
responsive: true,
maintainAspectRatio: false,
...
}
}
Thatโs works for me. Hope it helps someone.
Source:stackexchange.com