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-bar',
|
2017-05-16 19:02:54 +03:00
|
|
|
styles: [
|
|
|
|
|
`
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
],
|
|
|
|
|
template: `
|
|
|
|
|
<canvas baseChart
|
2017-07-27 12:06:50 +03:00
|
|
|
[datasets]="chartData"
|
|
|
|
|
[labels]="chartLabels"
|
|
|
|
|
[options]="chartOptions"
|
|
|
|
|
[legend]="chartLegend"
|
|
|
|
|
[chartType]="chartType"></canvas>
|
2017-05-16 19:02:54 +03:00
|
|
|
`,
|
|
|
|
|
})
|
2017-07-26 19:59:47 +03:00
|
|
|
export class ChartjsBarComponent {
|
2017-07-27 12:06:50 +03:00
|
|
|
chartLabels: string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
|
|
|
|
|
chartType: string = 'bar';
|
|
|
|
|
chartLegend: boolean = true;
|
|
|
|
|
chartData: any[] = [
|
2017-05-16 19:02:54 +03:00
|
|
|
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
|
|
|
|
|
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' },
|
|
|
|
|
];
|
2017-07-28 16:09:02 +03:00
|
|
|
chartOptions: any;
|
|
|
|
|
|
|
|
|
|
constructor(private theme: NgaThemeService) {
|
|
|
|
|
this.theme.getJsTheme().subscribe(config => {
|
|
|
|
|
this.chartOptions = {
|
|
|
|
|
scaleShowVerticalLines: false,
|
|
|
|
|
responsive: true,
|
|
|
|
|
legend: {
|
|
|
|
|
labels: {
|
|
|
|
|
fontColor: config.chartjsBarLegendTextColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
scales: {
|
|
|
|
|
xAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
|
|
|
|
color: config.chartjsBarXAxisColor,
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
fontColor: config.chartjsBarTickColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
yAxes: [
|
|
|
|
|
{
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: true,
|
|
|
|
|
color: config.chartjsBarYAxisColor,
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
fontColor: config.chartjsBarTickColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-05-16 19:02:54 +03:00
|
|
|
}
|