NG2-Charts Can't bind to 'datasets' since it isn't a known property of 'canvas'
Solution 1:
Try importing ChartsModule in your app.module.ts like this-
import { ChartsModule } from 'ng2-charts/ng2-charts';
imports: [
.....
ChartsModule
.....
]
Solution 2:
I had the very same problem. I found on github that you just have to insert the ChartsModule in the submodule as well. First you add in app.module.ts
and the, in my case, reports.module.ts
.
Solution 3:
I'm working with ng2-charts + Angular 7 + Ionic 4, and I spent several hours searching for a solution. And this finally worked to me (after following the initial steps, of course, like installing ng2-charts and charts.js). Just import ChartsModule on the following files:
app.module.ts
import { ChartsModule } from 'ng2-charts';
...
imports: [ChartsModule]
yourPage.module.ts
import { ChartsModule } from 'ng2-charts';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
RouterModule.forChild([{ path: '', component: YourPagePage }]),
**ChartsModule**
]
})
I was trying to import it also in yourPage.page.ts, but the solution was to import it in yourPage.module.ts!
Try it out.
Solution 4:
i'm working with [email protected]
looks like the property chartType
is now called type
so it should look something like this:
<canvas
style="display: block;background-color: #3a3939;"
width="600"
height="300"
id="canvas"
#myCanvas
baseChart
[type]="lineChartType"
[datasets]="lineChartData"
[labels]="lineChartLabels"
[options]="mfChartOptions"
[legend]="lineChartLegend">
</canvas>