My ng2-charts component is not updating its labels when I update the charts data at the same time in ngOnChanges()
.
If i comment out the data var update in ngOnChanges()
the labels update in the UI successfully. How can i get both my data and labels updated?
I would include my HTML and calling class but see no obvious issue - if you request it i will post it here.
Why does the labels not update when i un-comment my data update...the data updates just fine (along with other chart vars)
import { Component, Input, OnInit, NgZone, OnChanges } from '@angular/core';
@Component({
selector: 'app-bar-chart-demo',
templateUrl: './bar-chart-demo.component.html',
styleUrls: ['./bar-chart-demo.component.css'],
inputs:['chartLabel', 'chartData']
})
export class BarChartDemoComponent{
public barChartOptions:any = {
scaleShowVerticalLines:false,
responsive:true
};
//Labels
public barChartLabel:string[];
@Input() chartLabel:string[];
//Data
public barChartData:any[];
@Input() chartData:string[];
ngOnChanges(){
// this.barChartData=this.chartData;
this.barChartLabel=this.chartLabel;
}
ngOnInit(){
this.barChartLabel=this.chartLabel;
console.log("in onInit "+this.chartData);
this.barChartData=this.chartData;
}
}
}
My package.json shows the following charting libs
"chart.js": "^2.4.0", "ng2-charts": "^1.5.0",