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-line',
|
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]="chatyType"></canvas>
|
2017-05-16 19:02:54 +03:00
|
|
|
`,
|
|
|
|
|
})
|
2017-07-26 19:59:47 +03:00
|
|
|
export class ChartjsLineComponent {
|
2017-07-27 12:06:50 +03:00
|
|
|
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' },
|
|
|
|
|
{ data: [18, 48, 77, 9, 100, 27, 40], label: 'Series C' },
|
|
|
|
|
];
|
2017-07-27 12:06:50 +03:00
|
|
|
chartLabels: any[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
2017-07-28 16:09:02 +03:00
|
|
|
chartLegend: boolean = true;
|
|
|
|
|
chatyType: string = 'line';
|
|
|
|
|
chartOptions: any;
|
|
|
|
|
|
|
|
|
|
constructor(private theme: NgaThemeService) {
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2017-05-16 19:02:54 +03:00
|
|
|
},
|
2017-07-28 16:09:02 +03:00
|
|
|
legend: {
|
|
|
|
|
labels: {
|
2017-08-01 15:42:06 +03:00
|
|
|
fontColor: chartjs.legendTextColor,
|
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
|
|
|
}
|