Hello! I have been following the npm tutorial as link :ng2-charts - npm.
I tried to test pie chart on home.page : https://stackblitz.com/edit/ng2-charts-pie-template?file=src%2Fapp%2Fapp.component.css.
The error shows below :
TypeError: Object(…) is not a functionng2-charts.js:230:72
If i roll back to ng-charts version 2.2.3 from 2.3.0. The error is like :
Template parse error. Can’t bind ‘data’ since it’s not known of property of ‘canvas’.
I have been trying it for 2 days already. I tried other example too. it down’t work. I am stuck on here . Could you please help me?
Here is my ts file
import { Component,OnInit } from ‘@angular/core’;
import { ChartType, ChartOptions } from ‘chart.js’;
import { SingleDataSet, Label, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from ‘ng2-charts’;
@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {
// Pie
public pieChartOptions: ChartOptions = {
responsive: true,
};
public pieChartLabels: Label = [[‘Download’, ‘Sales’], [‘In’, ‘Store’, ‘Sales’], ‘Mail Sales’];
public pieChartData: SingleDataSet = [300, 500, 100];
public pieChartType: ChartType = ‘pie’;
public pieChartLegend = true;
public pieChartPlugins = ;
constructor() {
monkeyPatchChartJsTooltip();
monkeyPatchChartJsLegend();
}
ngOnInit() {
}
}