ng2-charts icon indicating copy to clipboard operation
ng2-charts copied to clipboard

ng2-chart does not redraw after update

Open manhar-developer opened this issue 5 years ago • 1 comments

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

} }

manhar-developer avatar Jun 26 '19 11:06 manhar-developer