mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-09-22 05:50:48 +02:00
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { Component, OnDestroy } from '@angular/core';
|
|
import { NbThemeService } from '@nebular/theme';
|
|
|
|
@Component({
|
|
selector: 'ngx-d3-bar',
|
|
template: `
|
|
<ngx-charts-bar-vertical
|
|
[scheme]="colorScheme"
|
|
[results]="results"
|
|
[xAxis]="showXAxis"
|
|
[yAxis]="showYAxis"
|
|
[legend]="showLegend"
|
|
[xAxisLabel]="xAxisLabel"
|
|
[yAxisLabel]="yAxisLabel">
|
|
</ngx-charts-bar-vertical>
|
|
`,
|
|
})
|
|
export class D3BarComponent implements OnDestroy {
|
|
|
|
results = [
|
|
{ name: 'Germany', value: 8940 },
|
|
{ name: 'USA', value: 5000 },
|
|
{ name: 'France', value: 7200 },
|
|
];
|
|
showLegend = true;
|
|
showXAxis = true;
|
|
showYAxis = true;
|
|
xAxisLabel = 'Country';
|
|
yAxisLabel = 'Population';
|
|
colorScheme: any;
|
|
themeSubscription: any;
|
|
|
|
constructor(private theme: NbThemeService) {
|
|
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
|
|
const colors: any = config.variables;
|
|
this.colorScheme = {
|
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
|
};
|
|
});
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
this.themeSubscription.unsubscribe();
|
|
}
|
|
}
|