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 with Top N Series

In this example, the PieChart component displays only top N values and aggregates the remainder into the others category.

www.wikipedia.org
Backend API
<dx-pie-chart id="pie" type="doughnut" title="Top Internet Languages" palette="Soft Pastel" [dataSource]="internetLanguages" > <dxo-pie-chart-export [enabled]="true"></dxo-pie-chart-export> <dxo-pie-chart-legend horizontalAlignment="center" verticalAlignment="bottom" ></dxo-pie-chart-legend> <dxi-pie-chart-series argumentField="language" valueField="percent"> <dxo-pie-chart-small-values-grouping mode="topN" [topCount]="3" ></dxo-pie-chart-small-values-grouping> <dxo-pie-chart-label [visible]="true" format="fixedPoint" [customizeText]="customizeLabel" > <dxo-pie-chart-connector [visible]="true" [width]="1" ></dxo-pie-chart-connector> </dxo-pie-chart-label> </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 { LanguageData, 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 { internetLanguages: LanguageData[]; constructor(service: Service) { this.internetLanguages = service.getLanguagesData(); } customizeLabel(point) { return `${point.argumentText}: ${point.valueText}%`; } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep #pie { height: 440px; }
import { Injectable, } from '@angular/core'; export class LanguageData { language: string; percent: number; } const languages: LanguageData[] = [{ language: 'English', percent: 55.5, }, { language: 'Chinese', percent: 4.0, }, { language: 'Spanish', percent: 4.3, }, { language: 'Japanese', percent: 4.9, }, { language: 'Portuguese', percent: 2.3, }, { language: 'German', percent: 5.6, }, { language: 'French', percent: 3.8, }, { language: 'Russian', percent: 6.3, }, { language: 'Italian', percent: 1.6, }, { language: 'Polish', percent: 1.8, }]; @Injectable() export class Service { getLanguagesData(): LanguageData[] { return languages; } }
<!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>