DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Charts - Doughnut Selection

This demo illustrates how a user can select slices on the PieChart component with the doughnut series type.

www.wikipedia.org
Backend API
<dx-pie-chart id="pie" type="doughnut" title="Olympic Medals in 2008" palette="Soft Pastel" [dataSource]="olympicMedals" (onPointClick)="pointClickHandler($event)" > <dxo-pie-chart-export [enabled]="true"></dxo-pie-chart-export> <dxo-pie-chart-legend [margin]="0" horizontalAlignment="right" verticalAlignment="top" ></dxo-pie-chart-legend> <dxi-pie-chart-series argumentField="country" valueField="medals"> <dxo-pie-chart-hover-style color="#ffd700"></dxo-pie-chart-hover-style> </dxi-pie-chart-series> </dx-pie-chart>
import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core'; import { DxPieChartModule } from 'devextreme-angular'; import { MedalsInfo, Service } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [Service], imports: [ DxPieChartModule, ], }) export class AppComponent { olympicMedals: MedalsInfo[]; constructor(service: Service) { this.olympicMedals = service.getMedalsData(); } pointClickHandler(arg) { arg.target.select(); } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep #pie { height: 440px; }
import { Injectable, } from '@angular/core'; export class MedalsInfo { country: string; medals: number; } const medals: MedalsInfo[] = [{ country: 'USA', medals: 110, }, { country: 'China', medals: 100, }, { country: 'Russia', medals: 72, }, { country: 'Britain', medals: 47, }, { country: 'Australia', medals: 46, }, { country: 'Germany', medals: 41, }, { country: 'France', medals: 40, }, { country: 'South Korea', medals: 31, }]; @Injectable() export class Service { getMedalsData(): MedalsInfo[] { return medals; } }
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>