mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 23:40:14 +01:00
refactor(charts): change color scheme for d3 charts
This commit is contained in:
parent
bdca59b793
commit
933881f69e
10 changed files with 70 additions and 128 deletions
|
|
@ -81,14 +81,5 @@ export const COSMIC_THEME = {
|
||||||
axisLineColor: '#a1a1e5',
|
axisLineColor: '#a1a1e5',
|
||||||
textColor: '#ffffff',
|
textColor: '#ffffff',
|
||||||
},
|
},
|
||||||
|
|
||||||
d3: {
|
|
||||||
pie: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
bar: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
line: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
advancedPie: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
areaStack: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
polar: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -75,14 +75,5 @@ export const DEFAULT_THEME = {
|
||||||
axisLineColor: '#cccccc',
|
axisLineColor: '#cccccc',
|
||||||
textColor: '#484848',
|
textColor: '#484848',
|
||||||
},
|
},
|
||||||
|
|
||||||
d3: {
|
|
||||||
pie: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
bar: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
line: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
advancedPie: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
areaStack: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
polar: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-advanced-pie',
|
selector: 'ngx-d3-advanced-pie',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-advanced-pie-chart
|
<ngx-charts-advanced-pie-chart
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="single">
|
[results]="single">
|
||||||
</ngx-charts-advanced-pie-chart>
|
</ngx-charts-advanced-pie-chart>
|
||||||
|
|
@ -26,13 +25,13 @@ export class D3AdvancedPieComponent {
|
||||||
value: 7200000,
|
value: 7200000,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
view: any[] = [700, 400];
|
|
||||||
colorScheme: any;
|
colorScheme: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).advancedPie,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-area-stack',
|
selector: 'ngx-d3-area-stack',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-area-chart
|
<ngx-charts-area-chart
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="multi"
|
[results]="multi"
|
||||||
[xAxis]="showXAxis"
|
[xAxis]="showXAxis"
|
||||||
|
|
@ -20,50 +19,34 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class D3AreaStackComponent {
|
export class D3AreaStackComponent {
|
||||||
multi = [
|
multi = [{
|
||||||
{
|
|
||||||
name: 'Germany',
|
name: 'Germany',
|
||||||
series: [
|
series: [{
|
||||||
{
|
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 7300000,
|
value: 7300000,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 8940000,
|
value: 8940000,
|
||||||
},
|
}],
|
||||||
],
|
}, {
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'USA',
|
name: 'USA',
|
||||||
series: [
|
series: [{
|
||||||
{
|
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 7870000,
|
value: 7870000,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 8270000,
|
value: 8270000,
|
||||||
},
|
}],
|
||||||
],
|
}, {
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'France',
|
name: 'France',
|
||||||
series: [
|
series: [{
|
||||||
{
|
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 5000002,
|
value: 5000002,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 5800000,
|
value: 5800000,
|
||||||
},
|
}],
|
||||||
],
|
}];
|
||||||
},
|
|
||||||
];
|
|
||||||
view: any[] = [700, 400];
|
|
||||||
showLegend = true;
|
showLegend = true;
|
||||||
autoScale = true;
|
autoScale = true;
|
||||||
showXAxis = true;
|
showXAxis = true;
|
||||||
|
|
@ -76,8 +59,9 @@ export class D3AreaStackComponent {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).areaStack,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,49 +5,35 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-bar',
|
selector: 'ngx-d3-bar',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-bar-vertical
|
<ngx-charts-bar-vertical
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="single"
|
[results]="results"
|
||||||
[xAxis]="showXAxis"
|
[xAxis]="showXAxis"
|
||||||
[yAxis]="showYAxis"
|
[yAxis]="showYAxis"
|
||||||
[legend]="showLegend"
|
[legend]="showLegend"
|
||||||
[showXAxisLabel]="showXAxisLabel"
|
|
||||||
[showYAxisLabel]="showYAxisLabel"
|
|
||||||
[xAxisLabel]="xAxisLabel"
|
[xAxisLabel]="xAxisLabel"
|
||||||
[yAxisLabel]="yAxisLabel">
|
[yAxisLabel]="yAxisLabel">
|
||||||
</ngx-charts-bar-vertical>
|
</ngx-charts-bar-vertical>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class D3BarComponent {
|
export class D3BarComponent {
|
||||||
single = [
|
|
||||||
{
|
results = [
|
||||||
name: 'Germany',
|
{ name: 'Germany', value: 8940 },
|
||||||
value: 8940000,
|
{ name: 'USA', value: 5000 },
|
||||||
},
|
{ name: 'France', value: 7200 },
|
||||||
{
|
|
||||||
name: 'USA',
|
|
||||||
value: 5000000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'France',
|
|
||||||
value: 7200000,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
view: any[] = [700, 400];
|
|
||||||
showLegend = true;
|
showLegend = true;
|
||||||
showXAxis = true;
|
showXAxis = true;
|
||||||
showYAxis = true;
|
showYAxis = true;
|
||||||
showLabels = true;
|
|
||||||
showXAxisLabel = true;
|
|
||||||
xAxisLabel = 'Country';
|
xAxisLabel = 'Country';
|
||||||
showYAxisLabel = true;
|
|
||||||
yAxisLabel = 'Population';
|
yAxisLabel = 'Population';
|
||||||
colorScheme: any;
|
colorScheme: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).bar,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-line',
|
selector: 'ngx-d3-line',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-line-chart
|
<ngx-charts-line-chart
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="multi"
|
[results]="multi"
|
||||||
[xAxis]="showXAxis"
|
[xAxis]="showXAxis"
|
||||||
|
|
@ -25,11 +24,11 @@ export class D3LineComponent {
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 7300000,
|
value: 7300,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 8940000,
|
value: 8940,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -38,11 +37,11 @@ export class D3LineComponent {
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 7870000,
|
value: 7870,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 8270000,
|
value: 8270,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -51,20 +50,18 @@ export class D3LineComponent {
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: '2010',
|
name: '2010',
|
||||||
value: 5000002,
|
value: 5002,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '2011',
|
name: '2011',
|
||||||
value: 5800000,
|
value: 5800,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
view: any[] = [700, 400];
|
|
||||||
showLegend = true;
|
showLegend = true;
|
||||||
showXAxis = true;
|
showXAxis = true;
|
||||||
showYAxis = true;
|
showYAxis = true;
|
||||||
showLabels = true;
|
|
||||||
showXAxisLabel = true;
|
showXAxisLabel = true;
|
||||||
xAxisLabel = 'Country';
|
xAxisLabel = 'Country';
|
||||||
showYAxisLabel = true;
|
showYAxisLabel = true;
|
||||||
|
|
@ -73,8 +70,9 @@ export class D3LineComponent {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).line,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,44 +5,28 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-pie',
|
selector: 'ngx-d3-pie',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-pie-chart
|
<ngx-charts-pie-chart
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="single"
|
[results]="results"
|
||||||
[legend]="showLegend"
|
[legend]="showLegend"
|
||||||
[labels]="showLabels">
|
[labels]="showLabels">
|
||||||
</ngx-charts-pie-chart>
|
</ngx-charts-pie-chart>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class D3PieComponent {
|
export class D3PieComponent {
|
||||||
single = [
|
results = [
|
||||||
{
|
{ name: 'Germany', value: 8940 },
|
||||||
name: 'Germany',
|
{ name: 'USA', value: 5000 },
|
||||||
value: 8940000,
|
{ name: 'France', value: 7200 },
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'USA',
|
|
||||||
value: 5000000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'France',
|
|
||||||
value: 7200000,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
view: any[] = [700, 400];
|
|
||||||
showLegend = true;
|
showLegend = true;
|
||||||
showXAxis = true;
|
|
||||||
showYAxis = true;
|
|
||||||
showLabels = true;
|
showLabels = true;
|
||||||
showXAxisLabel = true;
|
|
||||||
xAxisLabel = 'Country';
|
|
||||||
showYAxisLabel = true;
|
|
||||||
yAxisLabel = 'Population';
|
|
||||||
colorScheme: any;
|
colorScheme: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).pie,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
selector: 'ngx-d3-polar',
|
selector: 'ngx-d3-polar',
|
||||||
template: `
|
template: `
|
||||||
<ngx-charts-polar-chart
|
<ngx-charts-polar-chart
|
||||||
[view]="view"
|
|
||||||
[scheme]="colorScheme"
|
[scheme]="colorScheme"
|
||||||
[results]="multi"
|
[results]="multi"
|
||||||
[xAxis]="showXAxis"
|
[xAxis]="showXAxis"
|
||||||
|
|
@ -73,7 +72,6 @@ export class D3PolarComponent {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
view: any[] = [700, 400];
|
|
||||||
showLegend = true;
|
showLegend = true;
|
||||||
autoScale = true;
|
autoScale = true;
|
||||||
showXAxis = true;
|
showXAxis = true;
|
||||||
|
|
@ -86,8 +84,9 @@ export class D3PolarComponent {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService) {
|
||||||
this.theme.getJsTheme().subscribe(config => {
|
this.theme.getJsTheme().subscribe(config => {
|
||||||
|
const colors: any = config.variables;
|
||||||
this.colorScheme = {
|
this.colorScheme = {
|
||||||
domain: (<any>config.variables.d3).polar,
|
domain: [colors.primaryLight, colors.infoLight, colors.successLight, colors.warningLight, colors.dangerLight],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,14 @@
|
||||||
@import '../../../@theme/styles/themes';
|
@import '../../../@theme/styles/themes';
|
||||||
|
|
||||||
@include nb-install-component() {
|
@include nb-install-component() {
|
||||||
|
ngx-d3-bar,
|
||||||
|
ngx-d3-pie,
|
||||||
|
ngx-d3-advanced-pie,
|
||||||
|
ngx-d3-area-stack,
|
||||||
|
ngx-d3-line,
|
||||||
|
ngx-d3-polar {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ export const MENU_ITEMS: List<NbMenuItem> = List([{
|
||||||
children: List<NbMenuItem>([{
|
children: List<NbMenuItem>([{
|
||||||
title: 'Echarts',
|
title: 'Echarts',
|
||||||
link: '/pages/charts/echarts',
|
link: '/pages/charts/echarts',
|
||||||
}, {
|
|
||||||
title: 'D3',
|
|
||||||
link: '/pages/charts/d3',
|
|
||||||
}, {
|
}, {
|
||||||
title: 'Charts.js',
|
title: 'Charts.js',
|
||||||
link: '/pages/charts/chartjs',
|
link: '/pages/charts/chartjs',
|
||||||
|
}, {
|
||||||
|
title: 'D3',
|
||||||
|
link: '/pages/charts/d3',
|
||||||
}]),
|
}]),
|
||||||
}, {
|
}, {
|
||||||
title: 'Editors',
|
title: 'Editors',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue