ng2-charts
ng2-charts copied to clipboard
ng2-chart does not redraw after update
Reproduction of the problem Refer Stackblitz url
Adding dataset to the existing chart dynamically. Currently Chart has two data sets which displays two bars one is new and other is repeat. Upon click another dataset has been added to the existing dataset object. While checking the value in console it gives/print the output with updated dataset
export class AppComponent implements AfterViewInit { @ViewChild(BaseChartDirective) chart: any;
ngAfterViewInit() {
this.updateDataset();`data`
}
public chartData: BarChartDataset[] =
updateDataset(){
let marketVal = { data: [0 , 0, 30 , 100], label: 'New Data'}
// this.chartData.pop();
// Added chart data set dynamically upon click. Upon click another dataset has been added to the existing dataset object. While checking the value in cosnole it gives/print the
this.chartData.push(marketVal);
console.log(this.chartData);
console.log(this.chart);
this.chart.chart.update();
//updated chart
} }