feat(charts): integrate js theme with chart.js

This commit is contained in:
Alexander Zhukov 2017-07-28 16:09:02 +03:00
parent 0f0bea801d
commit bc536dbded
7 changed files with 335 additions and 183 deletions

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { NgaThemeService } from '@akveo/nga-theme';
@Component({
selector: 'ngx-chartjs-bar',
@ -19,39 +20,6 @@ import { Component } from '@angular/core';
`,
})
export class ChartjsBarComponent {
chartOptions: any = {
scaleShowVerticalLines: false,
responsive: true,
legend: {
labels: {
fontColor: 'white',
},
},
scales: {
xAxes: [
{
gridLines: {
display: true,
color: 'rgba(148,159,177,1)',
},
ticks: {
fontColor: 'white',
},
},
],
yAxes: [
{
gridLines: {
display: true,
color: 'rgba(148,159,177,1)',
},
ticks: {
fontColor: 'white',
},
},
],
},
};
chartLabels: string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
chartType: string = 'bar';
chartLegend: boolean = true;
@ -59,4 +27,43 @@ export class ChartjsBarComponent {
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' },
];
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,
},
},
],
},
};
});
}
}