Line Chart
This feature allows you to create a line chart using ng2-charts. The code sample demonstrates how to set up the chart data, labels, options, colors, and type in an Angular component.
{"template":"<canvas baseChart [datasets]=\"lineChartData\" [labels]=\"lineChartLabels\" [options]=\"lineChartOptions\" [colors]=\"lineChartColors\" [legend]=\"lineChartLegend\" [chartType]=\"lineChartType\"></canvas>","component":"import { Component } from '@angular/core';\n\n@Component({\n selector: 'app-line-chart',\n templateUrl: './line-chart.component.html'\n})\nexport class LineChartComponent {\n public lineChartData: Array<any> = [\n { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },\n { data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' }\n ];\n public lineChartLabels: Array<any> = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];\n public lineChartOptions: any = {\n responsive: true\n };\n public lineChartColors: Array<any> = [\n { // grey\n backgroundColor: 'rgba(148,159,177,0.2)',\n borderColor: 'rgba(148,159,177,1)',\n pointBackgroundColor: 'rgba(148,159,177,1)',\n pointBorderColor: '#fff',\n pointHoverBackgroundColor: '#fff',\n pointHoverBorderColor: 'rgba(148,159,177,0.8)'\n },\n { // dark grey\n backgroundColor: 'rgba(77,83,96,0.2)',\n borderColor: 'rgba(77,83,96,1)',\n pointBackgroundColor: 'rgba(77,83,96,1)',\n pointBorderColor: '#fff',\n pointHoverBackgroundColor: '#fff',\n pointHoverBorderColor: 'rgba(77,83,96,1)'\n }\n ];\n public lineChartLegend: boolean = true;\n public lineChartType: string = 'line';\n}"}
Bar Chart
This feature allows you to create a bar chart using ng2-charts. The code sample demonstrates how to set up the chart data, labels, options, and type in an Angular component.
{"template":"<canvas baseChart [datasets]=\"barChartData\" [labels]=\"barChartLabels\" [options]=\"barChartOptions\" [colors]=\"barChartColors\" [legend]=\"barChartLegend\" [chartType]=\"barChartType\"></canvas>","component":"import { Component } from '@angular/core';\n\n@Component({\n selector: 'app-bar-chart',\n templateUrl: './bar-chart.component.html'\n})\nexport class BarChartComponent {\n public barChartOptions: any = {\n scaleShowVerticalLines: false,\n responsive: true\n };\n public barChartLabels: string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];\n public barChartType: string = 'bar';\n public barChartLegend: boolean = true;\n public barChartData: any[] = [\n { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },\n { data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' }\n ];\n}"}
Pie Chart
This feature allows you to create a pie chart using ng2-charts. The code sample demonstrates how to set up the chart data, labels, and type in an Angular component.
{"template":"<canvas baseChart [data]=\"pieChartData\" [labels]=\"pieChartLabels\" [chartType]=\"pieChartType\"></canvas>","component":"import { Component } from '@angular/core';\n\n@Component({\n selector: 'app-pie-chart',\n templateUrl: './pie-chart.component.html'\n})\nexport class PieChartComponent {\n public pieChartLabels: string[] = ['Download Sales', 'In-Store Sales', 'Mail Sales'];\n public pieChartData: number[] = [300, 500, 100];\n public pieChartType: string = 'pie';\n}"}