[Chartjs]-Can't bind to 'data' since it isn't a known property of 'canvas'

33๐Ÿ‘

โœ…

I needed to import the ChartModule in the module.ts file of the component that I wanted to use the chart in. I originally only had it imported in app.module.ts.

20๐Ÿ‘

Try using the attribute syntax for binding:

Instead of:

[data]="doughnutChartData"

Try:

attr.data="{{doughnutChartData}}"

Iโ€™m not certain if this will work in your case, but this has to do with whatโ€™s a DOM property versus an attribute, and how Angular handles binding for both.

3๐Ÿ‘

In the app.module.ts file, within the NgModule decorater there is an array called imports, mention ChartsModule in the imports array like this

imports: [BrowserModule, RouterModule.forRoot(appRoutes),ChartsModule ],

It helped me. It can be helpful to you as well

1๐Ÿ‘

For Angular 7 or greater version use

npm install ng2-charts@2.2.3

โ€“save npm install chart.js โ€“save

Leave a comment