2016-05-11 17:38:01 +03:00
|
|
|
import {Component, ViewEncapsulation, ElementRef} from '@angular/core';
|
2016-05-04 18:11:13 +03:00
|
|
|
|
|
|
|
|
import './trafficChart.loader.ts';
|
|
|
|
|
import {TrafficChartService} from './trafficChart.service';
|
2016-05-04 17:18:09 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'traffic-chart',
|
|
|
|
|
encapsulation: ViewEncapsulation.None,
|
2016-05-04 18:11:13 +03:00
|
|
|
providers: [TrafficChartService],
|
2016-05-04 17:18:09 +03:00
|
|
|
styles: [require('./trafficChart.scss')],
|
|
|
|
|
template: require('./trafficChart.html')
|
|
|
|
|
})
|
2016-05-13 10:43:29 +03:00
|
|
|
|
|
|
|
|
// TODO: move chart.js to it's own component
|
2016-05-04 17:18:09 +03:00
|
|
|
export class TrafficChart {
|
|
|
|
|
|
2016-05-04 18:11:13 +03:00
|
|
|
public doughnutData: Array<Object>;
|
2016-05-16 18:46:23 +03:00
|
|
|
public transparent:boolean = false;
|
2016-05-04 17:18:09 +03:00
|
|
|
|
2016-05-04 18:11:13 +03:00
|
|
|
constructor(private trafficChartService:TrafficChartService) {
|
|
|
|
|
this.doughnutData = trafficChartService.getData();
|
2016-05-16 18:46:23 +03:00
|
|
|
this.transparent = trafficChartService.getTransparent();
|
2016-05-04 17:18:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
2016-05-04 18:11:13 +03:00
|
|
|
this._loadDoughnutCharts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _loadDoughnutCharts() {
|
|
|
|
|
let el = $('.chart-area').get(0);
|
2016-05-04 17:18:09 +03:00
|
|
|
new Chart(el.getContext('2d')).Doughnut(this.doughnutData, {
|
|
|
|
|
segmentShowStroke: false,
|
|
|
|
|
percentageInnerCutout : 64,
|
|
|
|
|
responsive: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|