@shikshalokam/sl-reports
Version:
Library to integrate questionnaire in SL Projects
33 lines (29 loc) • 1.06 kB
text/typescript
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import { Label, SingleDataSet } from 'ng2-charts';
export class PieChartComponent implements OnInit {
data;
questionNumber;
chartRootElement;
chartCanvas;
public pieChartOptions: ChartOptions = {
responsive: true,
legend: { position: 'bottom', align:'start'},
};
public pieChartLabels: Label[];
public pieChartData: SingleDataSet;
public pieChartType: ChartType = 'pie';
public pieChartLegend = true;
public chartColors: Array<any>;
constructor() {}
ngOnInit() {
this.pieChartLabels = this.data.chart.data.labels;
this.pieChartData = this.data.chart.data.datasets[0].data;
this.chartColors = [{ backgroundColor: this.data.chart.data.datasets[0].backgroundColor }];
}
}