2017-05-16 19:02:54 +03:00
|
|
|
import { Component } from '@angular/core';
|
2017-07-31 15:03:12 +03:00
|
|
|
import { NgaThemeService } from '@akveo/nga-theme';
|
2017-05-16 19:02:54 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ngx-d3-line',
|
|
|
|
|
template: `
|
|
|
|
|
<ngx-charts-line-chart
|
|
|
|
|
[view]="view"
|
|
|
|
|
[scheme]="colorScheme"
|
|
|
|
|
[results]="multi"
|
|
|
|
|
[xAxis]="showXAxis"
|
|
|
|
|
[yAxis]="showYAxis"
|
|
|
|
|
[legend]="showLegend"
|
|
|
|
|
[showXAxisLabel]="showXAxisLabel"
|
|
|
|
|
[showYAxisLabel]="showYAxisLabel"
|
|
|
|
|
[xAxisLabel]="xAxisLabel"
|
|
|
|
|
[yAxisLabel]="yAxisLabel">
|
|
|
|
|
</ngx-charts-line-chart>
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
export class D3LineComponent {
|
2017-07-27 12:06:50 +03:00
|
|
|
multi = [
|
|
|
|
|
{
|
|
|
|
|
name: 'Germany',
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '2010',
|
|
|
|
|
value: 7300000,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '2011',
|
|
|
|
|
value: 8940000,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'USA',
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '2010',
|
|
|
|
|
value: 7870000,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '2011',
|
|
|
|
|
value: 8270000,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'France',
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '2010',
|
|
|
|
|
value: 5000002,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '2011',
|
|
|
|
|
value: 5800000,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
];
|
2017-05-16 19:02:54 +03:00
|
|
|
view: any[] = [700, 400];
|
|
|
|
|
showLegend = true;
|
|
|
|
|
showXAxis = true;
|
|
|
|
|
showYAxis = true;
|
|
|
|
|
showLabels = true;
|
|
|
|
|
showXAxisLabel = true;
|
|
|
|
|
xAxisLabel = 'Country';
|
|
|
|
|
showYAxisLabel = true;
|
|
|
|
|
yAxisLabel = 'Population';
|
2017-07-31 15:03:12 +03:00
|
|
|
colorScheme: any;
|
|
|
|
|
|
|
|
|
|
constructor(private theme: NgaThemeService) {
|
|
|
|
|
this.theme.getJsTheme().subscribe(config => {
|
|
|
|
|
this.colorScheme = {
|
2017-08-01 15:42:06 +03:00
|
|
|
domain: (<any>config.variables.d3).line,
|
2017-07-31 15:03:12 +03:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-05-16 19:02:54 +03:00
|
|
|
}
|