Simple Demo and Example of PIE Chart in AngularJS Using ChartJS

In this post i will let you know how to show PIE chart in angular application using angular-chart.js chart library.This chart library is angular version of JavaScript chart.js library.You can download angular charts library from Here .

Angular Charts is a HTML5 based charting library which is creating chart on canvas html5 element.Angular Charts is lightweight and popular charting library in JavaScript.The main features of angular_chart.js are responsive, Reactive and html5 supported Chart library.You can create beautiful charts for AngularJS using Chart.js library.

pie-charts-angularjs-demo

Checkout other tutorial of Charting,

Angular-chart is a native AngularJS directives for Chart.js. The following required dependencies are:

  • AngularJS (tested with 1.2.x, 1.3.x and 1.4.x although it probably works with older versions)
  • Chart.js (requires Chart.js 1.0, tested with version 1.0.1 and 1.0.2).

Step 1: Included all dependency files of angular charts.

Step 2: inject dependency in angular module.

Step 3: Define Data an labels for PIE charts.We need to assigned all labels in chartLabels array and data into chartData JavaScript array,Please make sure labels and datas series will not mismatch.

Step 4: Define Chart directory in HTML file and assigned model to it.

How To get value of clicked slice in PIE chart

Sometimes we need to preform some operation on click of PIE chart slice, so below code will help to get clickes slice value of PIE chart.

charts.js provides onClickSlice="" callback method which is fired when PIE chart clicked and get slice value.

Download Code and Demo Link

Leave a Reply

Your email address will not be published. Required fields are marked *