Topic: Angular line graph updating data
Start your code here private updateChartData(newDataValues: number[] | any[]): void { if (Array.isArray(newDataValues[0].data)) { this.chart.data.datasets.forEach((dataset: any, i: number) => { dataset.data = newDataValues[i].data;if (newDataValues[i].label) { dataset.label = newDataValues[i].label; } }); } else { this.chart.data.datasets[0].data = newDataValues; } }What am i doing wrong?
Damian Gemza staff answered 7 years ago
ngAfterViewInit() { setTimeout(() => { this.chartDatasets= [ { data: [12, 12, 12, 12, 126, 12, 12], label: 'Second' }, { data: [], label: '' }, ]; }, 3000); }
majnor pro commented 7 years ago
Thx for the quick answer. From your answer it sounds like you cannot change the number of dataset, which is what i was trying to do, is this understood correctly? But it is possible to replace on of the datasets with a empty one, right? Regards, MajaDamian Gemza staff commented 7 years ago
Yes, exactly. If you need to remove some datasets, you have to set it as empty one. Best Regards, DamianFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: Yes
- Provided link: No