I'm using the ng2-chart library and I want to pass the information of a parent component to the child comonent. I get the information from an API that provides me with the data. But it is not loading the information:
export class PruebasComponent implements OnInit {
lineChartData: ChartDataSets[];
lineChartLabels: Label[];
In the ngOnInit I get the data
ngOnInit() {
this.loading = true;
this.datos.getDesktopLimit().subscribe(
res => {
this.loading = false;
this.data = [res];
this.dataSource = this.data[0];
this.barChartData = true;
this.getFilter(this.dataSource);
}
)
}
and through the getFilter () function I can modify the data I want to send:
getFilter(data) {
data.sort((a, b) => a.id - b.id);
for (let entry of data) {
this.date.push(moment(entry.created).format('DD-MM-YYYY HH:mm'))
this.time.push(entry.total_load_time * 0.001)
}
this.lineChartData = [{ data: this.time, label: 'Time Render' }] /* [ { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' }] */;
this.lineChartLabels = this.date;
this.loading = false
}
[datasets] sends the empty data
<app-graphic [datasets]="lineChartData" [labels]="lineChartLabels"></app-graphic>
OnPushstrategy ?app-graphic? Is this your own component? If so show the code, if not post a link to the library you're using. Are you familiar with the basics Pass data from parent to child with input binding ?