ngx-admin/src/app/pages/charts/chartjs/chartjs-line.component.ts

70 lines
1.7 KiB
TypeScript
Raw Normal View History

import { Component } from '@angular/core';
import { NgaThemeService } from '@akveo/nga-theme';
@Component({
2017-07-27 12:06:50 +03:00
selector: 'ngx-chartjs-line',
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>
`,
})
export class ChartjsLineComponent {
2017-07-27 12:06:50 +03:00
chartData: any[] = [
{ 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'];
chartLegend: boolean = true;
chatyType: string = 'line';
chartOptions: any;
constructor(private theme: NgaThemeService) {
this.theme.getJsTheme().subscribe(config => {
this.chartOptions = {
responsive: true,
scales: {
xAxes: [
{
gridLines: {
display: true,
color: config.chartjsLineXAxisColor,
},
ticks: {
fontColor: config.chartjsLineTickColor,
},
},
],
yAxes: [
{
gridLines: {
display: true,
color: config.chartjsLineYAxisColor,
},
ticks: {
fontColor: config.chartjsLineTickColor,
},
},
],
},
legend: {
labels: {
fontColor: config.chartjsLineLegendTextColor,
2017-07-27 12:06:50 +03:00
},
},
};
});
}
}