ngx-admin/src/app/pages/dashboard/trafficChart/trafficChart.component.ts

35 lines
828 B
TypeScript
Raw Normal View History

2017-01-21 16:46:34 +03:00
import {Component} from '@angular/core';
2016-05-04 18:11:13 +03:00
import {TrafficChartService} from './trafficChart.service';
import * as Chart from 'chart.js';
2016-05-04 17:18:09 +03:00
2017-01-21 16:46:34 +03:00
import 'style-loader!./trafficChart.scss';
2016-05-04 17:18:09 +03:00
@Component({
selector: 'traffic-chart',
templateUrl: './trafficChart.html'
2016-05-04 17:18:09 +03:00
})
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-04 17:18:09 +03:00
2016-05-04 18:11:13 +03:00
constructor(private trafficChartService:TrafficChartService) {
this.doughnutData = trafficChartService.getData();
2016-05-04 17:18:09 +03:00
}
ngAfterViewInit() {
2016-05-04 18:11:13 +03:00
this._loadDoughnutCharts();
}
private _loadDoughnutCharts() {
let el = jQuery('.chart-area').get(0) as HTMLCanvasElement;
2016-05-04 17:18:09 +03:00
new Chart(el.getContext('2d')).Doughnut(this.doughnutData, {
segmentShowStroke: false,
percentageInnerCutout : 64,
responsive: true
});
}
}