ngx-admin/src/app/theme/components/baAmChart/baAmChart.component.ts

32 lines
920 B
TypeScript
Raw Normal View History

2016-05-11 17:38:01 +03:00
import {Component, ViewEncapsulation, Input, Output, ElementRef, EventEmitter} from '@angular/core';
2016-05-06 13:28:11 +03:00
import './baAmChart.loader.ts';
import {BaAmChartThemeService} from './baAmChartTheme.service';
2016-05-06 13:28:11 +03:00
@Component({
selector: 'ba-am-chart',
template: require('./baAmChart.html'),
encapsulation: ViewEncapsulation.None,
providers: [BaAmChartThemeService],
2016-05-06 13:28:11 +03:00
})
export class BaAmChart {
@Input() baAmChartConfiguration:Object;
@Input() baAmChartClass:string;
@Output() onChartReady = new EventEmitter<any>();
constructor (private _elementRef:ElementRef, private _baAmChartThemeService:BaAmChartThemeService) {
}
ngOnInit() {
AmCharts.themes.blur = this._baAmChartThemeService.getTheme();
2016-05-06 13:28:11 +03:00
}
ngAfterViewInit() {
2016-05-11 17:38:01 +03:00
let el = this._elementRef.nativeElement.querySelector('.ba-am-chart');
2016-05-06 13:28:11 +03:00
let chart = AmCharts.makeChart(el, this.baAmChartConfiguration);
this.onChartReady.emit(chart);
}
}