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';
|
2016-05-06 16:10:51 +03:00
|
|
|
import {BaAmChartThemeService} from './baAmChartTheme.service';
|
2016-05-06 13:28:11 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ba-am-chart',
|
|
|
|
|
template: require('./baAmChart.html'),
|
2016-05-06 16:10:51 +03:00
|
|
|
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>();
|
|
|
|
|
|
2016-05-06 16:10:51 +03:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|