mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-09-22 05:50:48 +02:00
feat(charts): add chart.js examples page
This commit is contained in:
parent
626da294c4
commit
cf23f972d1
22 changed files with 657 additions and 264 deletions
|
@ -35,7 +35,8 @@
|
|||
"../node_modules/tinymce/plugins/link/plugin.js",
|
||||
"../node_modules/tinymce/plugins/paste/plugin.js",
|
||||
"../node_modules/tinymce/plugins/table/plugin.js",
|
||||
"../node_modules/echarts/dist/echarts.js"
|
||||
"../node_modules/echarts/dist/echarts.js",
|
||||
"../node_modules/chart.js/dist/Chart.js"
|
||||
],
|
||||
"environmentSource": "environments/environment.ts",
|
||||
"environments": {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
"@swimlane/ngx-charts": "5.2.0",
|
||||
"angular2-echarts": "1.1.7",
|
||||
"bootstrap": "4.0.0-alpha.6",
|
||||
"chart.js": "2.5.0",
|
||||
"ckeditor": "4.6.2",
|
||||
"classlist.js": "1.1.20150312",
|
||||
"core-js": "2.4.1",
|
||||
|
@ -50,6 +51,7 @@
|
|||
"intl": "1.2.5",
|
||||
"ionicons": "2.0.1",
|
||||
"leaflet": "1.0.3",
|
||||
"ng2-charts": "1.5.0",
|
||||
"ng2-ckeditor": "1.1.6",
|
||||
"normalize.css": "6.0.0",
|
||||
"roboto-fontface": "0.7.0",
|
||||
|
|
64
src/app/pages/charts/chart.js/bar/bar.component.ts
Normal file
64
src/app/pages/charts/chart.js/bar/bar.component.ts
Normal file
|
@ -0,0 +1,64 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-chart-js-bar',
|
||||
styles: [
|
||||
`
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
],
|
||||
template: `
|
||||
<canvas baseChart
|
||||
[datasets]="barChartData"
|
||||
[labels]="barChartLabels"
|
||||
[options]="barChartOptions"
|
||||
[legend]="barChartLegend"
|
||||
[chartType]="barChartType"></canvas>
|
||||
`,
|
||||
})
|
||||
export class ChartJsBarComponent {
|
||||
|
||||
barChartOptions: 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',
|
||||
},
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
barChartLabels: string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
|
||||
|
||||
barChartType: string = 'bar';
|
||||
|
||||
barChartLegend: boolean = true;
|
||||
|
||||
barChartData: any[] = [
|
||||
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
|
||||
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' },
|
||||
];
|
||||
|
||||
}
|
26
src/app/pages/charts/chart.js/chart-js.component.html
Normal file
26
src/app/pages/charts/chart.js/chart-js.component.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<nga-card size="xmedium">
|
||||
<nga-card-header>Pie</nga-card-header>
|
||||
<nga-card-body>
|
||||
<ngx-chart-js-pie></ngx-chart-js-pie>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<nga-card size="xmedium">
|
||||
<nga-card-header>Bar</nga-card-header>
|
||||
<nga-card-body>
|
||||
<ngx-chart-js-bar></ngx-chart-js-bar>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<nga-card size="xmedium">
|
||||
<nga-card-header>Line</nga-card-header>
|
||||
<nga-card-body>
|
||||
<ngx-chart-js-line></ngx-chart-js-line>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
</div>
|
9
src/app/pages/charts/chart.js/chart-js.component.ts
Normal file
9
src/app/pages/charts/chart.js/chart-js.component.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-chart-js',
|
||||
templateUrl: './chart-js.component.html',
|
||||
})
|
||||
|
||||
export class ChartJsComponent {
|
||||
}
|
64
src/app/pages/charts/chart.js/line/line.component.ts
Normal file
64
src/app/pages/charts/chart.js/line/line.component.ts
Normal file
|
@ -0,0 +1,64 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-chart-js-line',
|
||||
styles: [
|
||||
`
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
],
|
||||
template: `
|
||||
<canvas baseChart
|
||||
[datasets]="lineChartData"
|
||||
[labels]="lineChartLabels"
|
||||
[options]="lineChartOptions"
|
||||
[legend]="lineChartLegend"
|
||||
[chartType]="lineChartType"></canvas>
|
||||
`,
|
||||
})
|
||||
export class ChartJsLineComponent {
|
||||
|
||||
lineChartData: any[] = [
|
||||
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
|
||||
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' },
|
||||
{ data: [18, 48, 77, 9, 100, 27, 40], label: 'Series C' },
|
||||
];
|
||||
|
||||
lineChartLabels: any[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
||||
|
||||
lineChartOptions: any = {
|
||||
responsive: true,
|
||||
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',
|
||||
},
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
labels: {
|
||||
fontColor: 'white',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
lineChartLegend: boolean = true;
|
||||
|
||||
lineChartType: string = 'line';
|
||||
|
||||
}
|
54
src/app/pages/charts/chart.js/pie/pie.component.ts
Normal file
54
src/app/pages/charts/chart.js/pie/pie.component.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-chart-js-pie',
|
||||
styles: [
|
||||
`
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
],
|
||||
template: `
|
||||
<canvas baseChart
|
||||
[data]="pieChartData"
|
||||
[labels]="pieChartLabels"
|
||||
[options]="pieChartOptions"
|
||||
[chartType]="pieChartType"></canvas>
|
||||
`,
|
||||
})
|
||||
export class ChartJsPieComponent {
|
||||
|
||||
pieChartType: string = 'pie';
|
||||
pieChartLabels: string[] = ['Download Sales', 'In-Store Sales', 'Mail Sales'];
|
||||
pieChartData: number[] = [300, 500, 100];
|
||||
pieChartOptions: any = {
|
||||
responsive: true,
|
||||
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',
|
||||
},
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
labels: {
|
||||
fontColor: 'white',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import { Routes, RouterModule } from '@angular/router';
|
|||
import { ChartsComponent } from './charts.component';
|
||||
import { EchartsComponent } from './echarts/echarts.component';
|
||||
import { D3Component } from './d3/d3.component';
|
||||
import { ChartJsComponent } from './chart.js/chart-js.component';
|
||||
|
||||
const routes: Routes = [{
|
||||
path: '',
|
||||
|
@ -14,6 +15,9 @@ const routes: Routes = [{
|
|||
}, {
|
||||
path: 'd3',
|
||||
component: D3Component,
|
||||
}, {
|
||||
path: 'chartjs',
|
||||
component: ChartJsComponent,
|
||||
}],
|
||||
}];
|
||||
|
||||
|
@ -27,4 +31,5 @@ export const routedComponents = [
|
|||
ChartsComponent,
|
||||
EchartsComponent,
|
||||
D3Component,
|
||||
ChartJsComponent,
|
||||
];
|
||||
|
|
|
@ -4,6 +4,27 @@ import { NgaChartsModule } from '@nga/theme';
|
|||
import { SharedModule } from '../../shared.module';
|
||||
|
||||
import { ChartsRoutingModule, routedComponents } from './charts-routing.module';
|
||||
import { ChartJsBarComponent } from './chart.js/bar/bar.component';
|
||||
import { ChartJsLineComponent } from './chart.js/line/line.component';
|
||||
import { ChartJsPieComponent } from './chart.js/pie/pie.component';
|
||||
import { D3BarComponent } from './d3/bar/bar.component';
|
||||
import { D3LineComponent } from './d3/line/line.component';
|
||||
import { D3PieComponent } from './d3/pie/pie.component';
|
||||
import { EchartsLineComponent } from './echarts/line/line.component';
|
||||
import { EchartsPieComponent } from './echarts/pie/pie.component';
|
||||
import { EchartsBarComponent } from './echarts/bar/bar.component';
|
||||
|
||||
const components = [
|
||||
ChartJsBarComponent,
|
||||
ChartJsLineComponent,
|
||||
ChartJsPieComponent,
|
||||
D3BarComponent,
|
||||
D3LineComponent,
|
||||
D3PieComponent,
|
||||
EchartsLineComponent,
|
||||
EchartsPieComponent,
|
||||
EchartsBarComponent,
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -13,6 +34,7 @@ import { ChartsRoutingModule, routedComponents } from './charts-routing.module';
|
|||
],
|
||||
declarations: [
|
||||
...routedComponents,
|
||||
...components,
|
||||
],
|
||||
})
|
||||
export class ChartsModule { }
|
||||
|
|
55
src/app/pages/charts/d3/bar/bar.component.ts
Normal file
55
src/app/pages/charts/d3/bar/bar.component.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-d3-bar',
|
||||
template: `
|
||||
<ngx-charts-bar-vertical
|
||||
[view]="view"
|
||||
[scheme]="colorScheme"
|
||||
[results]="single"
|
||||
[xAxis]="showXAxis"
|
||||
[yAxis]="showYAxis"
|
||||
[legend]="showLegend"
|
||||
[showXAxisLabel]="showXAxisLabel"
|
||||
[showYAxisLabel]="showYAxisLabel"
|
||||
[xAxisLabel]="xAxisLabel"
|
||||
[yAxisLabel]="yAxisLabel">
|
||||
</ngx-charts-bar-vertical>
|
||||
`,
|
||||
})
|
||||
export class D3BarComponent {
|
||||
|
||||
single = [{
|
||||
name: 'Germany',
|
||||
value: 8940000,
|
||||
}, {
|
||||
name: 'USA',
|
||||
value: 5000000,
|
||||
}, {
|
||||
name: 'France',
|
||||
value: 7200000,
|
||||
}];
|
||||
|
||||
view: any[] = [700, 400];
|
||||
|
||||
showLegend = true;
|
||||
|
||||
colorScheme = {
|
||||
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
||||
};
|
||||
|
||||
showXAxis = true;
|
||||
|
||||
showYAxis = true;
|
||||
|
||||
showLabels = true;
|
||||
|
||||
showXAxisLabel = true;
|
||||
|
||||
xAxisLabel = 'Country';
|
||||
|
||||
showYAxisLabel = true;
|
||||
|
||||
yAxisLabel = 'Population';
|
||||
|
||||
}
|
|
@ -3,13 +3,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Pie</nga-card-header>
|
||||
<nga-card-body>
|
||||
<ngx-charts-pie-chart
|
||||
[view]="view"
|
||||
[scheme]="colorScheme"
|
||||
[results]="single"
|
||||
[legend]="showLegend"
|
||||
[labels]="showLabels">
|
||||
</ngx-charts-pie-chart>
|
||||
<ngx-d3-pie></ngx-d3-pie>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
@ -17,18 +11,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Bar</nga-card-header>
|
||||
<nga-card-body>
|
||||
<ngx-charts-bar-vertical
|
||||
[view]="view"
|
||||
[scheme]="colorScheme"
|
||||
[results]="single"
|
||||
[xAxis]="showXAxis"
|
||||
[yAxis]="showYAxis"
|
||||
[legend]="showLegend"
|
||||
[showXAxisLabel]="showXAxisLabel"
|
||||
[showYAxisLabel]="showYAxisLabel"
|
||||
[xAxisLabel]="xAxisLabel"
|
||||
[yAxisLabel]="yAxisLabel">
|
||||
</ngx-charts-bar-vertical>
|
||||
<ngx-d3-bar></ngx-d3-bar>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
@ -38,18 +21,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Line</nga-card-header>
|
||||
<nga-card-body>
|
||||
<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>
|
||||
<ngx-d3-line></ngx-d3-line>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
|
|
@ -5,66 +5,4 @@ import { Component } from '@angular/core';
|
|||
templateUrl: './d3.component.html',
|
||||
})
|
||||
export class D3Component {
|
||||
|
||||
single = [{
|
||||
name: 'Germany',
|
||||
value: 8940000,
|
||||
}, {
|
||||
name: 'USA',
|
||||
value: 5000000,
|
||||
}, {
|
||||
name: 'France',
|
||||
value: 7200000,
|
||||
}];
|
||||
|
||||
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,
|
||||
}],
|
||||
}];
|
||||
|
||||
view: any[] = [700, 400];
|
||||
|
||||
showLegend = true;
|
||||
|
||||
colorScheme = {
|
||||
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
||||
};
|
||||
|
||||
showXAxis = true;
|
||||
|
||||
showYAxis = true;
|
||||
|
||||
showLabels = true;
|
||||
|
||||
showXAxisLabel = true;
|
||||
|
||||
xAxisLabel = 'Country';
|
||||
|
||||
showYAxisLabel = true;
|
||||
|
||||
yAxisLabel = 'Population';
|
||||
}
|
||||
|
|
73
src/app/pages/charts/d3/line/line.component.ts
Normal file
73
src/app/pages/charts/d3/line/line.component.ts
Normal file
|
@ -0,0 +1,73 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@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 {
|
||||
|
||||
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,
|
||||
}],
|
||||
}];
|
||||
|
||||
view: any[] = [700, 400];
|
||||
|
||||
showLegend = true;
|
||||
|
||||
colorScheme = {
|
||||
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
||||
};
|
||||
|
||||
showXAxis = true;
|
||||
|
||||
showYAxis = true;
|
||||
|
||||
showLabels = true;
|
||||
|
||||
showXAxisLabel = true;
|
||||
|
||||
xAxisLabel = 'Country';
|
||||
|
||||
showYAxisLabel = true;
|
||||
|
||||
yAxisLabel = 'Population';
|
||||
|
||||
}
|
46
src/app/pages/charts/d3/pie/pie.component.ts
Normal file
46
src/app/pages/charts/d3/pie/pie.component.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-d3-pie',
|
||||
template: `
|
||||
<ngx-charts-pie-chart [view]="view" [scheme]="colorScheme" [results]="single" [legend]="showLegend"
|
||||
[labels]="showLabels">
|
||||
</ngx-charts-pie-chart>
|
||||
`,
|
||||
})
|
||||
export class D3PieComponent {
|
||||
|
||||
single = [{
|
||||
name: 'Germany',
|
||||
value: 8940000,
|
||||
}, {
|
||||
name: 'USA',
|
||||
value: 5000000,
|
||||
}, {
|
||||
name: 'France',
|
||||
value: 7200000,
|
||||
}];
|
||||
|
||||
view: any[] = [700, 400];
|
||||
|
||||
showLegend = true;
|
||||
|
||||
colorScheme = {
|
||||
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
|
||||
};
|
||||
|
||||
showXAxis = true;
|
||||
|
||||
showYAxis = true;
|
||||
|
||||
showLabels = true;
|
||||
|
||||
showXAxisLabel = true;
|
||||
|
||||
xAxisLabel = 'Country';
|
||||
|
||||
showYAxisLabel = true;
|
||||
|
||||
yAxisLabel = 'Population';
|
||||
|
||||
}
|
59
src/app/pages/charts/echarts/bar/bar.component.ts
Normal file
59
src/app/pages/charts/echarts/bar/bar.component.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-echarts-bar',
|
||||
template: `
|
||||
<div echarts [options]="barChartOptions" class="echart"></div>
|
||||
`,
|
||||
})
|
||||
export class EchartsBarComponent {
|
||||
|
||||
barChartOptions = {
|
||||
|
||||
color: ['#3398DB'],
|
||||
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
},
|
||||
},
|
||||
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
|
||||
xAxis: [{
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
axisTick: {
|
||||
alignWithLabel: true,
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
yAxis: [{
|
||||
type: 'value',
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
series: [{
|
||||
name: 'Score',
|
||||
type: 'bar',
|
||||
barWidth: '60%',
|
||||
data: [10, 52, 200, 334, 390, 330, 220],
|
||||
}],
|
||||
};
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Pie</nga-card-header>
|
||||
<nga-card-body>
|
||||
<div echarts [options]="pieChartOptions" class="echart"></div>
|
||||
<ngx-echarts-pie></ngx-echarts-pie>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
@ -11,7 +11,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Bar</nga-card-header>
|
||||
<nga-card-body>
|
||||
<div echarts [options]="barChartOptions" class="echart"></div>
|
||||
<ngx-echarts-bar></ngx-echarts-bar>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
@ -21,7 +21,7 @@
|
|||
<nga-card size="xmedium">
|
||||
<nga-card-header>Line</nga-card-header>
|
||||
<nga-card-body>
|
||||
<div echarts [options]="lineChartOptions" class="echart"></div>
|
||||
<ngx-echarts-line></ngx-echarts-line>
|
||||
</nga-card-body>
|
||||
</nga-card>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
:host {
|
||||
display: block;
|
||||
|
||||
.echart {
|
||||
/deep/ .echart {
|
||||
height: calc(#{$nga-card-height-xmedium} - 50px);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,162 +6,4 @@ import { Component } from '@angular/core';
|
|||
templateUrl: './echarts.component.html',
|
||||
})
|
||||
export class EchartsComponent {
|
||||
|
||||
pieChartOptions = {
|
||||
|
||||
color: ['rgb(168, 56, 93)', 'rgb(122, 163, 229)', 'rgb(170, 227, 245)', 'rgb(173, 205, 237)', 'rgb(162, 126, 168)'],
|
||||
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b} : {c} ({d}%)',
|
||||
},
|
||||
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: ['USA', 'Germany', 'France', 'Canada', 'Russia'],
|
||||
textStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
|
||||
series: [{
|
||||
name: 'Countries',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: [{
|
||||
value: 335,
|
||||
name: 'Germany',
|
||||
}, {
|
||||
value: 310,
|
||||
name: 'France',
|
||||
}, {
|
||||
value: 234,
|
||||
name: 'Canada',
|
||||
}, {
|
||||
value: 135,
|
||||
name: 'Russia',
|
||||
}, {
|
||||
value: 1548,
|
||||
name: 'USA',
|
||||
}],
|
||||
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)',
|
||||
},
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
barChartOptions = {
|
||||
|
||||
color: ['#3398DB'],
|
||||
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
},
|
||||
},
|
||||
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
|
||||
xAxis: [{
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
axisTick: {
|
||||
alignWithLabel: true,
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
yAxis: [{
|
||||
type: 'value',
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
series: [{
|
||||
name: 'Score',
|
||||
type: 'bar',
|
||||
barWidth: '60%',
|
||||
data: [10, 52, 200, 334, 390, 330, 220],
|
||||
}],
|
||||
};
|
||||
|
||||
lineChartOptions = {
|
||||
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b} : {c}',
|
||||
},
|
||||
|
||||
legend: {
|
||||
left: 'left',
|
||||
data: ['Line 1', 'Line 2', 'Line 3'],
|
||||
textStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
name: 'x',
|
||||
splitLine: { show: false },
|
||||
data: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
type: 'log',
|
||||
name: 'y',
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
series: [{
|
||||
name: 'Line 1',
|
||||
type: 'line',
|
||||
data: [1, 3, 9, 27, 81, 247, 741, 2223, 6669],
|
||||
}, {
|
||||
name: 'Line 2',
|
||||
type: 'line',
|
||||
data: [1, 2, 4, 8, 16, 32, 64, 128, 256],
|
||||
}, {
|
||||
name: 'Line 3',
|
||||
type: 'line',
|
||||
data: [1 / 2, 1 / 4, 1 / 8, 1 / 16, 1 / 32, 1 / 64, 1 / 128, 1 / 256, 1 / 512],
|
||||
}],
|
||||
};
|
||||
|
||||
}
|
||||
|
|
70
src/app/pages/charts/echarts/line/line.component.ts
Normal file
70
src/app/pages/charts/echarts/line/line.component.ts
Normal file
|
@ -0,0 +1,70 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-echarts-line',
|
||||
template: `
|
||||
<div echarts [options]="lineChartOptions" class="echart"></div>
|
||||
`,
|
||||
})
|
||||
export class EchartsLineComponent {
|
||||
|
||||
lineChartOptions = {
|
||||
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b} : {c}',
|
||||
},
|
||||
|
||||
legend: {
|
||||
left: 'left',
|
||||
data: ['Line 1', 'Line 2', 'Line 3'],
|
||||
textStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
name: 'x',
|
||||
splitLine: { show: false },
|
||||
data: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
type: 'log',
|
||||
name: 'y',
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
series: [{
|
||||
name: 'Line 1',
|
||||
type: 'line',
|
||||
data: [1, 3, 9, 27, 81, 247, 741, 2223, 6669],
|
||||
}, {
|
||||
name: 'Line 2',
|
||||
type: 'line',
|
||||
data: [1, 2, 4, 8, 16, 32, 64, 128, 256],
|
||||
}, {
|
||||
name: 'Line 3',
|
||||
type: 'line',
|
||||
data: [1 / 2, 1 / 4, 1 / 8, 1 / 16, 1 / 32, 1 / 64, 1 / 128, 1 / 256, 1 / 512],
|
||||
}],
|
||||
};
|
||||
|
||||
}
|
61
src/app/pages/charts/echarts/pie/pie.component.ts
Normal file
61
src/app/pages/charts/echarts/pie/pie.component.ts
Normal file
|
@ -0,0 +1,61 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-echarts-pie',
|
||||
template: `
|
||||
<div echarts [options]="pieChartOptions" class="echart"></div>|
|
||||
`,
|
||||
})
|
||||
export class EchartsPieComponent {
|
||||
|
||||
pieChartOptions = {
|
||||
|
||||
color: ['rgb(168, 56, 93)', 'rgb(122, 163, 229)', 'rgb(170, 227, 245)', 'rgb(173, 205, 237)', 'rgb(162, 126, 168)'],
|
||||
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b} : {c} ({d}%)',
|
||||
},
|
||||
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: ['USA', 'Germany', 'France', 'Canada', 'Russia'],
|
||||
textStyle: {
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
|
||||
series: [{
|
||||
name: 'Countries',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: [{
|
||||
value: 335,
|
||||
name: 'Germany',
|
||||
}, {
|
||||
value: 310,
|
||||
name: 'France',
|
||||
}, {
|
||||
value: 234,
|
||||
name: 'Canada',
|
||||
}, {
|
||||
value: 135,
|
||||
name: 'Russia',
|
||||
}, {
|
||||
value: 1548,
|
||||
name: 'USA',
|
||||
}],
|
||||
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)',
|
||||
},
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
}
|
|
@ -56,6 +56,9 @@ export const menuItems: List<NgaMenuItem> = List([{
|
|||
}, {
|
||||
title: 'D3',
|
||||
link: '/pages/charts/d3',
|
||||
}, {
|
||||
title: 'Charts.js',
|
||||
link: '/pages/charts/chartjs',
|
||||
}]),
|
||||
}, {
|
||||
title: 'Editors',
|
||||
|
|
43
yarn.lock
43
yarn.lock
|
@ -813,6 +813,26 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
|
|||
strip-ansi "^3.0.0"
|
||||
supports-color "^2.0.0"
|
||||
|
||||
chart.js@2.5.0, chart.js@^2.4.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.5.0.tgz#fe6e751a893769f56e72bee5ad91207e1c592957"
|
||||
dependencies:
|
||||
chartjs-color "^2.0.0"
|
||||
moment "^2.10.6"
|
||||
|
||||
chartjs-color-string@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/chartjs-color-string/-/chartjs-color-string-0.4.0.tgz#57748d4530ae28d8db0a5492182ba06dfdf2f468"
|
||||
dependencies:
|
||||
color-name "^1.0.0"
|
||||
|
||||
chartjs-color@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/chartjs-color/-/chartjs-color-2.1.0.tgz#9c39ac830ccd98996ae80c9f11086ff12c98a756"
|
||||
dependencies:
|
||||
chartjs-color-string "^0.4.0"
|
||||
color-convert "^0.5.3"
|
||||
|
||||
chokidar@^1.4.1, chokidar@^1.4.3, chokidar@^1.6.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
|
||||
|
@ -936,6 +956,10 @@ collections@^0.2.0:
|
|||
dependencies:
|
||||
weak-map "1.0.0"
|
||||
|
||||
color-convert@^0.5.3:
|
||||
version "0.5.3"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-0.5.3.tgz#bdb6c69ce660fadffe0b0007cc447e1b9f7282bd"
|
||||
|
||||
color-convert@^1.3.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
|
||||
|
@ -3536,6 +3560,10 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkd
|
|||
dependencies:
|
||||
minimist "0.0.8"
|
||||
|
||||
moment@^2.10.6:
|
||||
version "2.18.1"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
|
||||
|
||||
ms@0.7.1:
|
||||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
|
||||
|
@ -3575,6 +3603,12 @@ negotiator@0.6.1:
|
|||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
|
||||
|
||||
ng2-charts@1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/ng2-charts/-/ng2-charts-1.5.0.tgz#72556a1ff0f6758c21abc7eccfe71984c82e9c2d"
|
||||
dependencies:
|
||||
chart.js "^2.4.0"
|
||||
|
||||
ng2-ckeditor@1.1.6:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/ng2-ckeditor/-/ng2-ckeditor-1.1.6.tgz#fa3afb86982b725f7f3a609924c64821c2719875"
|
||||
|
@ -5992,20 +6026,13 @@ write-file-stdout@0.0.2:
|
|||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/write-file-stdout/-/write-file-stdout-0.0.2.tgz#c252d7c7c5b1b402897630e3453c7bfe690d9ca1"
|
||||
|
||||
ws@1.1.1:
|
||||
ws@1.1.1, ws@^1.0.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.1.tgz#082ddb6c641e85d4bb451f03d52f06eabdb1f018"
|
||||
dependencies:
|
||||
options ">=0.0.5"
|
||||
ultron "1.0.x"
|
||||
|
||||
ws@^1.0.1:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.4.tgz#57f40d036832e5f5055662a397c4de76ed66bf61"
|
||||
dependencies:
|
||||
options ">=0.0.5"
|
||||
ultron "1.0.x"
|
||||
|
||||
wtf-8@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue