Mahesh Verma

Mahesh Verma

  • 276
  • 6.4k
  • 1.1m

Angular2 chart updating issue

Apr 27 2018 6:32 AM
Currently, I am using the ng2 chart in my application, but I am unable to bind chart data dynamically.
 
My code is : 
  1. public barChartOptions:any = {  
  2.     scaleShowVerticalLines: false,  
  3.     responsive: true  
  4.   };  
  5.   public barChartLabels:string[] = ['Feb''Mar''Apr'];  
  6.   public barChartType:string = 'bar';  
  7.   public barChartLegend:boolean = true;  
  8.   public barChartData = [  
  9.     {data: [5,7,9], label: 'Activity'},  
  10.    ];  
  11.    
 Want to change "data" property inside the barChartData, like this : 
  1. const data0 = [ 8,8,9 ];     
  2. this.barChartData[0].data=data0;  
 Above lines i wrote inside ngOnInit().
 
I also go through these links :
https://stackoverflow.com/questions/39078061/dynamically-updated-ng2-charts
https://alligator.io/angular/chartjs-ng2-charts/
https://github.com/valor-software/ng2-charts/issues/859
 
But didn't get any solution, could you please help me out. 

Answers (1)