Example shows Angular Pie Chart with index / data labels that show information about the each slice of the chart.
/* app.component.ts */ import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; import { CanvasJSAngularChartsModule } from '@canvasjs/angular-charts'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, RouterOutlet, CanvasJSAngularChartsModule], templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { chartOptions = { animationEnabled: true, title: { text: "Sales by Department" }, data: [{ type: "pie", startAngle: -90, indexLabel: "{name}: {y}", yValueFormatString: "#,###.##'%'", dataPoints: [ { y: 14.1, name: "Toys" }, { y: 28.2, name: "Electronics" }, { y: 14.4, name: "Groceries" }, { y: 43.3, name: "Furniture" } ] }] } }
<div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
Indexlabel can be added to each slice by setting indexLabel property & it can be positioned either outside or inside the slice by setting indexLabelPlacement property. Radius of the pie can be changed by setting radius property. Some other commonly used customizations in pie chart includes explodeOnClick, exploded, etc.
Note For step by step instructions, follow our Angular Integration Tutorial