2017-05-16 19:02:54 +03:00
|
|
|
import { Component } from '@angular/core';
|
2017-07-28 16:09:02 +03:00
|
|
|
import { NgaThemeService } from '@akveo/nga-theme';
|
2017-05-16 19:02:54 +03:00
|
|
|
|
|
|
|
|
@Component({
|
2017-07-27 12:06:50 +03:00
|
|
|
selector: 'ngx-chartjs-pie',
|
2017-05-16 19:02:54 +03:00
|
|
|
styles: [
|
|
|
|
|
`
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
],
|
|
|
|
|
template: `
|
2017-07-28 16:09:02 +03:00
|
|
|
<canvas baseChart
|
2017-07-27 12:06:50 +03:00
|
|
|
[data]="chartData"
|
|
|
|
|
[labels]="chartLabels"
|
|
|
|
|
[options]="chartOptions"
|
|
|
|
|
[chartType]="chartType"></canvas>
|
2017-05-16 19:02:54 +03:00
|
|
|
`,
|
|
|
|
|
})
|
2017-07-26 19:59:47 +03:00
|
|
|
export class ChartjsPieComponent {
|
2017-07-27 12:06:50 +03:00
|
|
|
chartType: string = 'pie';
|
|
|
|
|
chartLabels: string[] = ['Download Sales', 'In-Store Sales', 'Mail Sales'];
|
|
|
|
|
chartData: number[] = [300, 500, 100];
|
2017-07-28 16:09:02 +03:00
|
|
|
chartOptions: any;
|
|
|
|
|
|
|
|
|
|
constructor(private theme: NgaThemeService) {
|
|
|
|
|
this.theme.getJsTheme().subscribe(config => {
|
|
|
|
|
this.chartOptions = {
|
|
|
|
|
responsive: true,
|
|
|
|
|
scales: {
|
|
|
|
|
xAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
|
|
|
|
color: config.chartjsPieXAxisColor,
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
fontColor: config.chartjsPitTickColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
yAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
|
|
|
|
color: config.chartjsPieYAxisColor,
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
fontColor: config.chartjsPieTickColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
labels: {
|
|
|
|
|
fontColor: config.chartjsPieLegendTextColor,
|
2017-07-27 12:06:50 +03:00
|
|
|
},
|
2017-05-16 19:02:54 +03:00
|
|
|
},
|
2017-07-28 16:09:02 +03:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-05-16 19:02:54 +03:00
|
|
|
}
|