Angular PieChart - Access a Label Using the API
NOTE
Before accessing a point label, you must gain access to its series point. You can learn the details in the Access a Point Using the API topic.
To access a point label, call the getLabel() method of its series point. This method returns an object described in the Label section of the API reference.
TypeScript
- 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;
- label: any = {};
- getPointLabel () {
- const series = this.pieChart.instance.getAllSeries()[0];
- const seriesPoints = series.getAllPoints();
- this.label = seriesPoints[0].getLabel();
- }
- }
- @NgModule({
- imports: [
- // ...
- DxPieChartModule
- ],
- // ...
- })
Once you access a label, you can, for example, hide or show it by calling the hide() or show() method.
JavaScript
- label.hide();
- // label.show();
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.