ngx-admin/src/app/pages/dashboard/trafficChart/trafficChart.component.ts
2017-01-27 14:52:14 +03:00

34 lines
828 B
TypeScript

import {Component} from '@angular/core';
import {TrafficChartService} from './trafficChart.service';
import * as Chart from 'chart.js';
import 'style-loader!./trafficChart.scss';
@Component({
selector: 'traffic-chart',
templateUrl: './trafficChart.html'
})
// TODO: move chart.js to it's own component
export class TrafficChart {
public doughnutData: Array<Object>;
constructor(private trafficChartService:TrafficChartService) {
this.doughnutData = trafficChartService.getData();
}
ngAfterViewInit() {
this._loadDoughnutCharts();
}
private _loadDoughnutCharts() {
let el = jQuery('.chart-area').get(0) as HTMLCanvasElement;
new Chart(el.getContext('2d')).Doughnut(this.doughnutData, {
segmentShowStroke: false,
percentageInnerCutout : 64,
responsive: true
});
}
}