93Alliance / ng-chartjs

A fully functional Angular2+ chart.js library.
https://93alliance.github.io/ng-chartjs/
MIT License
87 stars 10 forks source link

Dynamic line chart #10

Closed jagroopkbs closed 4 years ago

jagroopkbs commented 4 years ago

I am facing problem when i am trying to get datasets or labels by function . Probably the reason for this problem graph is loaded before the function call.

This is my chart: Component.html

<canvas ngChartjs [datasets]="lineChartData" [colors]="lineChartColors" [labels]="labels" [options]="lineChartOptions" [legend]="lineChartLegend" [chartType]="lineChartType" (chartHover)="chartHovered($event)"[inlinePlugins]="inlinePlugin" width="561" height="290" style="width: 561px; height: 290px;">

This is my Component.ts

ngOnInit() {

this.labels = ['Dec 17','Jan 18','Feb 18','Mar 18','Apr 18','May 18','Jun 18','Jul 18','Aug 18','Sep 18','Oct 18','Nov 18','Dec 18','Jan 19','Feb 19','Mar 19','Apr 19','May 19','Jun 19','Jul 19','Aug 19','Sep 19','Oct 19','Nov 19','Dec 19','Jan 20','Feb 20'];

}

lineChartLabels = this.labeltest

93Alliance commented 4 years ago

Could you describe the problem in detail?You can create demo by stackblitz