PieChart

The PieChart is a widget that visualizes data as a circle divided into sectors that each represents a portion of the whole.

Included in: dx.viz.js, dx.viz-web.js, dx.all.js
Module: viz/pie_chart
Export: default
PieChart interactive configuration
Copy Code
Copy to Codepen
$("#piechart").dxPieChart({
});

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the PieChart widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
var fruits = [
    { fruit: "Oranges", yield: 10, consumed: 7 },
    { fruit: "Apples", yield: 15, consumed: 14 },
    { fruit: "Bananas", yield: 9, consumed: 9 }
];
$(function() {
    $("#pieChart").dxPieChart({
        dataSource: fruits,
        commonSeriesSettings: {
            argumentField: "fruit"
        },
        series: [
            { valueField: "yield" },
            { valueField: "consumed" }
        ]
    });
});
<div id="pieChart"></div>
Angular
HTML
TypeScript
<dx-pie-chart [dataSource]="fruits">
    <dxo-common-series-settings argumentField="fruit"></dxo-common-series-settings>
    <dxi-series valueField="yield"></dxi-series>
    <dxi-series valueField="consumed"></dxi-series>
</dx-pie-chart>
import { DxPieChartModule } from 'devextreme-angular';
// ...
export class AppComponent {
    fruits = [
        { fruit: "Oranges", yield: 10, consumed: 7 },
        { fruit: "Apples", yield: 15, consumed: 14 },
        { fruit: "Bananas", yield: 9, consumed: 9 }
    ];
}
@NgModule({
    imports: [
        // ...
        DxPieChartModule
    ],
    // ...
})
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-pie-chart="{
        dataSource: fruits,
        commonSeriesSettings: {
            argumentField: 'fruit'
        },
        series: [
            { valueField: 'yield' },
            { valueField: 'consumed' }
        ]
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.fruits = [
            { fruit: "Oranges", yield: 10, consumed: 7 },
            { fruit: "Apples", yield: 15, consumed: 14 },
            { fruit: "Bananas", yield: 9, consumed: 9 }   
        ];
    });
Knockout
HTML
JavaScript
<div data-bind="dxPieChart: {
    dataSource: fruits,
    commonSeriesSettings: {
        argumentField: 'fruit'
    },
    series: [
        { valueField: 'yield' },
        { valueField: 'consumed' }
    ]
}"></div>
var viewModel = {
    fruits: [
        { fruit: "Oranges", yield: 10, consumed: 7 },
        { fruit: "Apples", yield: 15, consumed: 14 },
        { fruit: "Bananas", yield: 9, consumed: 9 }
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().PieChart()
    .ID("pieChart")
    .DataSource(new[] {
        new { Fruit = "Oranges", Yield = 10, Consumed = 7 },
        new { Fruit = "Apples", Yield = 15, Consumed = 14 },
        new { Fruit = "Bananas", Yield = 9, Consumed = 9 }
    })
    .CommonSeriesSettings(c => c
        .ArgumentField("Fruit")
    )
    .Series(series => {
        series.Add().ValueField("Yield");
        series.Add().ValueField("Consumed");
    })
)
@(Html.DevExtreme().PieChart() _
    .ID("pieChart") _
    .DataSource({
        New With { .Fruit = "Oranges", .Yield = 10, .Consumed = 7 },
        New With { .Fruit = "Apples", .Yield = 15, .Consumed = 14 },
        New With { .Fruit = "Bananas", .Yield = 9, .Consumed = 9 }
    }) _
    .CommonSeriesSettings(Sub(c)
        c.ArgumentField("Fruit")
    End Sub) _
    .Series(Sub(series)
        series.Add().ValueField("Yield")
        series.Add().ValueField("Consumed")
    End Sub)

View Demo Watch Video

See Also

Configuration

An object that defines configuration options for the PieChart widget.

Methods

This section describes the methods that can be used in code to manipulate the PieChart widget.

Use the dxPieChart registered method to access the PieChart widget, as demonstrated in the code below.

var pieChart = $("#pieChartContainer").dxPieChart("instance");

Events

This section describes events fired by this widget.

See Also

Series Types

This section lists the objects that define options to be used to configure series of particular types.

Type:

Object

Chart Elements

This section describes chart elements.