All docs
V20.2
24.1
23.2
23.1
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.
A newer version of this page is available. Switch to the current version.

jQuery 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.

jQuery
JavaScript
var series = $("#pieChartContainer").dxPieChart("getAllSeries")[0];
var seriesPoints = series.getAllPoints();
var label = seriesPoints[0].getLabel();
Angular
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
    ],
    // ...
})
Vue
App.vue
<template> 
    <DxPieChart ...
        ref="pieChart">
    </DxPieChart>
</template>

<script>
import DxPieChart from 'devextreme-vue/pie-chart';

export default {
    components: {
        DxPieChart
    },
    data() {
        return {
            label: {}
        };
    },
    methods: {
        getPointLabel() {
            const series = this.$refs.pieChart.instance.getAllSeries()[0];
            const seriesPoints = series.getAllPoints();
            this.label = seriesPoints[0].getLabel();
        }
    }
}
</script>
React
App.js
import React from 'react';
import PieChart from 'devextreme-react/pie-chart';

class App extends React.Component {
    constructor(props) {
        super(props);

        this.pieChartRef = React.createRef();
        this.label = {};

        this.getPointLabel = this.getPointLabel.bind(this);
    }

    render() {
        return (
            <PieChart ...
                ref={this.pieChartRef}>
            </PieChart>
        );
    }

    get pieChart() {
        return this.pieChartRef.current.instance;
    }

    getPointLabel() {
        const series = this.pieChart.getAllSeries()[0];
        const seriesPoints = series.getAllPoints();
        this.label = seriesPoints[0].getLabel();
    }
}

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