<ejs-chart #sopChart id='chart' style='display:block;' [chartArea]='chartArea' align='center' [primaryXAxis]='primaryXAxis'in .ts I handle it like this
[primaryYAxis]='primaryYAxis' [title]='title'>
<e-series-collection>
<e-series type='Column' xName='abbrevDate' yName='value' name='Quantity' width=2 [marker]='marker'> </e-series>
</e-series-collection>
</ejs-chart>
@ViewChild('sopChart') _chart: ChartComponent;
ngOnInit() {
this.loadData(true);
}
filterData(args: IChangedEventArgs){
if(this.notFirstRun){
this.dataSource = this.dataSource.filter((data: { [key: string]: Object }): Boolean => {
return (data.date >= new Date(+args.start) && data.date <= new Date(+args.end));
});
this.loadData(false);
}
this.notFirstRun=true;
}
loadData(load: boolean) {
if(load){
console.log('LOAD DATA');
console.log(this._chart);
this.reportingService.getMainSalesReport().subscribe(
data => {
this.dataSource = data;
this._chart.series[0].dataSource = this.dataSource;
this._chart.refresh();
});
} else{
console.log('RELOAD DATA');
console.log(this._chart);
this._chart.series[0].dataSource = this.dataSource;
this._chart.refresh();
}
}
ngOnInit() {
this.sopComp = new ChartComponent();
}
public changed(args: IChangedEventArgs): void {
this.sopComp.filterData(args);
}
Class BarChartComponent() implements AfterViewInit{
//….
ngAfterViewInit() {
this.loadData(true);
}
}
|
Class BarChartComponent() implements AfterViewInit{
//….
ngOnInit() {
this.xName = ‘abbrevDate’
this.yName = ‘value’
this.loadData(true);
}
}
|