2016-05-06 13:28:11 +03:00
|
|
|
import {Component, ViewEncapsulation, Input, Output, ElementRef, EventEmitter} from 'angular2/core';
|
|
|
|
|
|
|
|
|
|
import './baAmChart.loader.ts';
|
|
|
|
|
import {DOM} from "angular2/src/platform/dom/dom_adapter";
|
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',
|
|
|
|
|
styles: [require('./baAmChart.scss')],
|
|
|
|
|
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() {
|
|
|
|
|
let el = DOM.querySelector(this._elementRef.nativeElement, '.ba-am-chart');
|
|
|
|
|
|
|
|
|
|
let chart = AmCharts.makeChart(el, this.baAmChartConfiguration);
|
|
|
|
|
this.onChartReady.emit(chart);
|
|
|
|
|
}
|
|
|
|
|
}
|