Example shows Angular Pie Chart in dark theme, where darker background is used & lighter colored text.
/* 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, theme: "dark2", title:{ text: "Social Media Engagement" }, data: [{ type: "pie", startAngle: 45, indexLabel: "{name}: {y}", indexLabelPlacement: "inside", yValueFormatString: "#,###.##'%'", dataPoints: [ { y: 21.3, name: "Facebook" }, { y: 27.7, name: "Instagram" }, { y: 17, name: "Twitter" }, { y: 14.9, name: "LinkedIn" }, { y: 10.6, name: "Pinterest" }, { y: 8.5, name: "Others" } ] }] } }
<div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
In the above example, theme is set to dark2 using theme property & index-labels are placed inside slice using indexLabelPlacement property. Some other common customizations in pie chart includes startAngle, radius, etc.
Note For step by step instructions, follow our Angular Integration Tutorial