You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initialize a chart with datasets=[] empty array (ex: when the user has to select the datasets and there are none selected by default)
Trigger change detection (ex: hover over chart)
Result: Errors show up in the console.
ERROR TypeError: Cannot set property 'data' of undefined
at BaseChartDirective.propagateDataToDatasets (valor-software-ng2-charts.umd.js? [sm]:1138)
at BaseChartDirective.ngDoCheck (valor-software-ng2-charts.umd.js? [sm]:652)
If later a dataset is added, the errors go away.
And if we remove again all datasets the errors don't come back. Only when the chart is initialized with an empty datasets array.
The problem is caused by this code from propagateDataToDatasets, which assumes that if datasets is defined, there is at least one dataset (see else block).
if(!this.datasets){this.datasets=[{data: newDataValues}];if(this.chart){this.chart.data.datasets=this.datasets;}}else{this.datasets[0].data=newDataValues;this.datasets.splice(1);// Remove all elements but the first}
The text was updated successfully, but these errors were encountered:
Hi there, we experience now weird behaviour when [datasets]="[]". baseChart code somehow replaces objects and inputs in just totally other part of applications. Mostly it somehow replaces angular Inputs with the chart related object for totally different components of our app
Reproduction of the problem
datasets=[]
empty array (ex: when the user has to select the datasets and there are none selected by default)Result: Errors show up in the console.
If later a dataset is added, the errors go away.
And if we remove again all datasets the errors don't come back. Only when the chart is initialized with an empty datasets array.
Demo: https://stackblitz.com/edit/angular-ivy-c8oztr?file=src%2Fapp%2Fapp.component.ts
The problem is caused by this code from propagateDataToDatasets, which assumes that if datasets is defined, there is at least one dataset (see else block).
The text was updated successfully, but these errors were encountered: