New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

ng2-charts

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-charts

Reactive, responsive, beautiful charts for Angular2 based on Chart.js


Version published
Weekly downloads
273K
decreased by-1.58%
Maintainers
1
Weekly downloads
 
Created

What is ng2-charts?

ng2-charts is an Angular wrapper for Chart.js, providing a way to create and manage various types of charts in Angular applications. It simplifies the integration of Chart.js into Angular projects by offering Angular components and directives.

What are ng2-charts's main functionalities?

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}"}

Other packages similar to ng2-charts

FAQs

Package last updated on 07 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts