2017-05-16 19:02:54 +03:00
|
|
|
import { Component } from '@angular/core';
|
2017-08-01 17:42:21 +03:00
|
|
|
import { NbThemeService } from '@nebular/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;
|
|
|
|
|
|
2017-08-01 17:42:21 +03:00
|
|
|
constructor(private theme: NbThemeService) {
|
2017-07-28 16:09:02 +03:00
|
|
|
this.theme.getJsTheme().subscribe(config => {
|
2017-08-01 15:42:06 +03:00
|
|
|
|
|
|
|
|
const chartjs: any = config.variables.chartjs;
|
|
|
|
|
|
2017-07-28 16:09:02 +03:00
|
|
|
this.chartOptions = {
|
|
|
|
|
responsive: true,
|
2017-08-01 15:42:06 +03:00
|
|
|
scale: {
|
|
|
|
|
pointLabels: {
|
|
|
|
|
fontSize: 14,
|
2017-08-28 13:34:21 +03:00
|
|
|
fontColor: chartjs.textColor,
|
2017-08-01 15:42:06 +03:00
|
|
|
},
|
|
|
|
|
},
|
2017-07-28 16:09:02 +03:00
|
|
|
scales: {
|
|
|
|
|
xAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
2017-08-01 15:42:06 +03:00
|
|
|
color: chartjs.xAxisColor,
|
2017-07-28 16:09:02 +03:00
|
|
|
},
|
|
|
|
|
ticks: {
|
2017-08-01 15:42:06 +03:00
|
|
|
fontColor: chartjs.tickColor,
|
2017-07-28 16:09:02 +03:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
yAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
2017-08-01 15:42:06 +03:00
|
|
|
color: chartjs.yAxisColor,
|
2017-07-28 16:09:02 +03:00
|
|
|
},
|
|
|
|
|
ticks: {
|
2017-08-01 15:42:06 +03:00
|
|
|
fontColor: chartjs.tickColor,
|
2017-07-28 16:09:02 +03:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
labels: {
|
2017-08-28 13:34:21 +03:00
|
|
|
fontColor: chartjs.textColor,
|
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
|
|
|
}
|