ng2-charts
ng2-charts copied to clipboard
Cannot bind to class property any more
This used to work, but seems to broken with Angular 8 and the latest ng2-charts library: When the data is not stored directly in a class field, but a property access is used instead, ng2-charts gets confused and shows much smaller bars than it should. I took the default bar chart sample and replaced:
public barChartData: ChartDataSets[] =
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' }
];
with
public get barChartData(): ChartDataSets[] {
return [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' }
];
}
See: https://stackblitz.com/edit/angular-wk11ks