DevExtreme Angular - Access a Point Using the API
Before accessing a series point, gain access to its series by calling the getAllSeries() method. You can call the getSeriesByName(seriesName) or getSeriesByPos(seriesIndex) method as an alternative for multi-series PieCharts.
jQuery
var series = $("#pieChartContainer").dxPieChart("getAllSeries")[0];
Angular
import { ..., ViewChild } from "@angular/core"; import { DxPieChartModule, DxPieChartComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxPieChartComponent, { static: false }) pieChart: DxPieChartComponent; // Prior to Angular 8 // @ViewChild(DxPieChartComponent) pieChart: DxPieChartComponent; series: any = []; getSeries() { this.series = this.pieChart.instance.getAllSeries()[0]; } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
Use the following methods to access series points. All of them return one or several objects whose fields and methods are described in the API reference's Point section.
getAllPoints()
Gets all the series points.jQuery
JavaScriptvar series = $("#pieChartContainer").dxPieChart("getAllSeries")[0]; var seriesPoints = series.getAllPoints();
Angular
TypeScriptimport { ..., ViewChild } from "@angular/core"; import { DxPieChartModule, DxPieChartComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxPieChartComponent, { static: false }) pieChart: DxPieChartComponent; // Prior to Angular 8 // @ViewChild(DxPieChartComponent) pieChart: DxPieChartComponent; seriesPoints: any = []; getSeriesPoints() { let series = this.pieChart.instance.getAllSeries()[0]; this.seriesPoints = series.getAllPoints(); } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
getPointsByArg(pointArg)
Gets those series points that have a specific argument.jQuery
JavaScriptvar chinaPoints = series.getPointsByArg("China");
Angular
TypeScriptimport { ..., ViewChild } from "@angular/core"; import { DxPieChartModule, DxPieChartComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxPieChartComponent, { static: false }) pieChart: DxPieChartComponent; // Prior to Angular 8 // @ViewChild(DxPieChartComponent) pieChart: DxPieChartComponent; chinaPoints: any = {}; getChinaPoints() { let series = this.pieChart.instance.getAllSeries()[0]; this.chinaPoints = series.getPointsByArg("China"); } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
getPointByPos(positionIndex)
Gets a point using its index. The index is zero-based.jQuery
JavaScriptvar firstPoint = series.getPointByPos(0);
Angular
TypeScriptimport { ..., ViewChild } from "@angular/core"; import { DxPieChartModule, DxPieChartComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxPieChartComponent, { static: false }) pieChart: DxPieChartComponent; // Prior to Angular 8 // @ViewChild(DxPieChartComponent) pieChart: DxPieChartComponent; firstPoint: any = {}; getFirstPoint() { let series = this.pieChart.instance.getAllSeries()[0]; this.firstPoint = series.getPointByPos(0); } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
getVisiblePoints()
Gets only visible series points.jQuery
JavaScriptvar visiblePoints = series.getVisiblePoints();
Angular
TypeScriptimport { ..., ViewChild } from "@angular/core"; import { DxPieChartModule, DxPieChartComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxPieChartComponent, { static: false }) pieChart: DxPieChartComponent; // Prior to Angular 8 // @ViewChild(DxPieChartComponent) pieChart: DxPieChartComponent; visiblePoints: any = []; getVisiblePoints() { let series = this.pieChart.instance.getAllSeries()[0]; this.visiblePoints = series.getVisiblePoints(); } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
Apart from the API methods, you can access a series point in the event handlers. For example, the onPointClick event handler gets the clicked series point in the argument.
jQuery
$(function() { $("#pieChartContainer").dxPieChart({ // ... onPointClick: function (e) { var point = e.target; // ... } }); });
Angular
<dx-pie-chart (onPointClick)="onPointClick($event)"> </dx-pie-chart>
import { DxPieChartModule } from "devextreme-angular"; // ... export class AppComponent { onPointClick (e) { let point = e.target; // ... }; } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
See Also
- Access a Point Label Using the API
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
If you have technical questions, please create a support ticket in the DevExpress Support Center.