Example shows Angular Pie Chart in dark theme, where darker background is used & lighter colored text.
/* app.component.ts */ import { Component } from '@angular/core'; @Component({ selector: 'app-root', 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" } ] }] } }
/* app.module.ts */ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import * as CanvasJSAngularChart from '../assets/canvasjs.angular.component'; var CanvasJSChart = CanvasJSAngularChart.CanvasJSChart; @NgModule({ declarations: [ AppComponent, CanvasJSChart ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
<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.