0

In my Angular4 - Node.js application I am getting the following error at run time.

Can't bind to 'data' since it isn't a known property of 'canvas'. ("iv>

][data]="doughnutChartData" [labels]="doughnutChartLabels" [chartType]="doughnutChartType" (chartHover"): ng:///AppModule/DashboardComponent.html

The component's module.ts file looks like this :

import { NgModule } from ''; import { CommonModule } from ''; import { ChartsModule as Ng2Charts } from 'ng2-charts'; import { DashboardRoutingModule } from './dashboard-routing.module'; import { DashboardComponent } from './dashboard.component'; import { TimelineComponent, NotificationComponent, ChatComponent } from './components'; import { StatModule } from '../shared'; @NgModule({ imports: [ CommonModule, Ng2Charts, DashboardRoutingModule, StatModule, ], declarations: [ DashboardComponent, TimelineComponent, NotificationComponent, ChatComponent ] }) export class DashboardModule { } 

The componenet.html file looks like this :

<div class="col col-sm-6"> <div class="card mb-3" style="border: none"> <div class="card-header claim-header-style" style="background: #FC0!important;color: #fff;"> SUSPECT REASON </div> <div class="card-block"> <canvas baseChart height="180px" [data]="doughnutChartData" [labels]="doughnutChartLabels" [chartType]="doughnutChartType" (chartHover)="chartHovered($event)" (chartClick)="chartClicked($event)"> </canvas> </div> </div> </div> <div class="col col-sm-6"> <div class="card mb-3" style="border:none;"> <div class="card-header claim-header-style" style="background: #28426b!important;color: #fff;"> REJECT REASON </div> <div class="card-block"> <canvas baseChart height="180px" [data]="doughnutChartData" [labels]="doughnutChartLabels" [chartType]="doughnutChartType" (chartHover)="chartHovered($event)" (chartClick)="chartClicked($event)"> </canvas> </div> </div> </div> 

What could be wrong here ?

1 Answer 1

1

Try to import 'chart.js' inside your component where you actually using canvas and do not reference chart.js in index. html <script> section if you doing so.

Also try to import ChartsModule in to your DashboardModule

imports: [ ChartsModule ] 

as for some reason you are not doing so.

Also checkout that issue

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.