fix dashboard chart darkmode
This commit is contained in:
parent
3030999262
commit
944e51b756
@ -174,7 +174,7 @@
|
|||||||
<div class="col-12 xl:col-6">
|
<div class="col-12 xl:col-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Sales Overview</h5>
|
<h5>Sales Overview</h5>
|
||||||
<p-chart type="line" [data]="chartData"></p-chart>
|
<p-chart type="line" [data]="chartData" [options]="chartOptions"></p-chart>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -2,6 +2,9 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { MenuItem } from 'primeng/api';
|
import { MenuItem } from 'primeng/api';
|
||||||
import { Product } from '../../api/product';
|
import { Product } from '../../api/product';
|
||||||
import { ProductService } from '../../service/productservice';
|
import { ProductService } from '../../service/productservice';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
import { ConfigService } from '../../service/app.config.service';
|
||||||
|
import { AppConfig } from '../../api/appconfig';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
@ -12,11 +15,22 @@ export class DashboardComponent implements OnInit {
|
|||||||
|
|
||||||
products: Product[];
|
products: Product[];
|
||||||
|
|
||||||
chartData:any;
|
chartData: any;
|
||||||
|
|
||||||
constructor(private productService: ProductService) {}
|
chartOptions: any;
|
||||||
|
|
||||||
|
subscription: Subscription;
|
||||||
|
|
||||||
|
config: AppConfig;
|
||||||
|
|
||||||
|
constructor(private productService: ProductService, public configService: ConfigService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.config = this.configService.config;
|
||||||
|
this.subscription = this.configService.configUpdate$.subscribe(config => {
|
||||||
|
this.config = config;
|
||||||
|
this.updateChartOptions();
|
||||||
|
});
|
||||||
this.productService.getProductsSmall().then(data => this.products = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
|
|
||||||
this.items = [
|
this.items = [
|
||||||
@ -46,4 +60,72 @@ export class DashboardComponent implements OnInit {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateChartOptions() {
|
||||||
|
if (this.config.dark)
|
||||||
|
this.applyDarkTheme();
|
||||||
|
else
|
||||||
|
this.applyLightTheme();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDarkTheme() {
|
||||||
|
this.chartOptions = {
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
labels: {
|
||||||
|
color: '#ebedef'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: {
|
||||||
|
ticks: {
|
||||||
|
color: '#ebedef'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: 'rgba(160, 167, 181, .3)',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
ticks: {
|
||||||
|
color: '#ebedef'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: 'rgba(160, 167, 181, .3)',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
applyLightTheme() {
|
||||||
|
this.chartOptions = {
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
labels: {
|
||||||
|
color: '#495057'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: {
|
||||||
|
ticks: {
|
||||||
|
color: '#495057'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: '#ebedef',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
ticks: {
|
||||||
|
color: '#495057'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: '#ebedef',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user