๐:0
Your code has a number of errors that need to be fixed in order to work.
In Angular 8, @ViewChild
expects a second parameter
@ViewChild('lineChart', {static: true}) private chartRef;
The chart should be created inside ngOnInit
, the canvas is not yet available at the time when the Component
is constructed. This is basically where the Error: Cannot read property 'nativeElement' of undefined
comes from.
scales.yAxes.ticks.callback
inside the chart options
is not properly defined as a function.
Also the canvas
needs to be enclosed in a div
.
Please have a look at the amended StackBlitz