The requested page is not available for the requested platform. You are viewing the content for Default platform.

PieChartView Class

Visualizes data as a pie (circular) chart.

Namespace: DevExpress.XamarinForms.Charts

Assembly: DevExpress.XamarinForms.Charts.dll

Declaration

public class PieChartView :
    ChartBaseView

Remarks

This view is useful when it is necessary to compare the percentage values of different point arguments in the same series, and to illustrate these values as easy to understand pie slices.

PieChartView's properties allow you to add data series to a chart, specify chart elements (legend, series labels, center label and hints), customize chart appearance and configure selection behavior.

Pie Chart Elements

Pie Series

A chart visualizes data series provide. Each series defines data appearance and behavior. The PieChartView can visualize the following series types:

Chart

Series Type

Pie

PieSeries

Displays data as circular graphic divided into slices to illustrate numerical proportion.

Donut

DonutSeries

Displays data as a pie chart with a hole in center.

Note

To display Cartesian series, use the ChartView view instead.

To add a series to a chart, add a PieSeries or DonutSeries object to the chart's PieChartView.Series collection.

using DevExpress.XamarinForms.Charts;
// ...

chart.Series.Add(new DonutSeries { Data = new SeriesData() });

// ...
class SeriesData : IPieSeriesData {
    List<KeyValuePair<string, double>> data;

    public SeriesData() {
        data = new List<KeyValuePair<string, double>>() {
            new KeyValuePair<string, double>("Income", 132826.00),
            new KeyValuePair<string, double>("Growth", 208816.0),
            new KeyValuePair<string, double>("Speculation", 24700.00),
            new KeyValuePair<string, double>("Hedge", 80114.00)
        };
    }
    public int GetDataCount() => data.Count;
    public string GetLabel(int index) => data[index].Key;
    public double GetValue(int index) => data[index].Value;
    public object GetKey(int index) => null;
}

Legend

Legend is a chart element that displays series and series points' designations. Assign a Legend object to the ChartBaseView.Legend property to add a legend to a chart.

<dxc:PieChartView>
    <dxc:PieChartView.Legend>
        <dxc:Legend Orientation="TopToBottom"
                    HorizontalPosition="RightOutside"
                    VerticalPosition="Center"/>
    </dxc:PieChartView.Legend>
</dxc:PieChartView>

Labels

Each series point can be accompanied by a text label representing data related to the point. These are series point labels (or series labels, for short).

Series labels are hidden by default. To display them, create the PieSeriesLabel class instance, adjust the label position and appearance, and assign the label to the PieSeries.Label property.

<dxc:PieChartView>
    <dxc:PieChartView.Series>
            <dxc:DonutSeries>
                <dxc:DonutSeries.Label>
                    <dxc:PieSeriesLabel Position="Inside" TextPattern="{}{VP}%"/>
                </dxc:DonutSeries.Label>
        </dxc:DonutSeries>
    </dxc:PieChartView.Series>
</dxc:PieChartView>

Center Label

Use the PieSeries.CenterLabel property to display arbitrary text or a total value in the center of the Doughnut chart.

<dxc:PieChartView>
    <dxc:PieChartView.Series>
            <dxc:DonutSeries>
                <dxc:DonutSeries.CenterLabel>
                    <dxc:PieCenterTextLabel TextPattern="{}Total&#x0a;{TV}"/>
                </dxc:DonutSeries.CenterLabel>
        </dxc:DonutSeries>
    </dxc:PieChartView.Series>
</dxc:PieChartView>

Hints

A chart can display hints with information about a tapped series or point.

  • To show hints, create a new PieHint object, set its Enabled property to True, and assign the hint to the chart's PieChartView.Hint property.

    <dxc:PieChartView>
        <dxc:PieChartView.Hint>
            <dxc:PieHint Enabled="True"/>
        </dxc:PieChartView.Hint>
    </dxc:PieChartView>
    
  • To format values hints display, assign a PieSeriesHintOptions object with the specified text pattern to the PieSeries.HintOptions property.

    <dxc:PieChartView>
        <dxc:PieChartView.Series>
            <dxc:DonutSeries>
                <dxc:DonutSeries.HintOptions>
                    <dxc:PieSeriesHintOptions PointTextPattern="{}{L}: {VP}%"/>
                </dxc:DonutSeries.HintOptions>
            </dxc:DonutSeries>
        </dxc:PieChartView.Series>
    </dxc:PieChartView>
    

Selection

PieChartView provides a set of properties you can use to manage the chart's behavior when an end-user taps a chart element:

Chart Appearance

To customize the pie chart appearance, assign a PieChartStyle object with the specified chart appearance settings to the PieChartView.ChartStyle property.

chart.ChartStyle = new PieChartStyle() {
    Palette = new Color[] {
        Color.FromHex("#b04972"),
        Color.FromHex("#9c5ba0"),
        Color.FromHex("#7145a8"),
        Color.FromHex("#1c7ed6"),
        Color.FromHex("#1db2f5"),
        Color.FromHex("#48b099"),
        Color.FromHex("#ffaf24"),
        Color.FromHex("#fe765e")},
    BackgroundColor = Color.FromHex("#2d3844"),
    SeriesIndent = 100
};

Pie Chart Elements

Inheritance

Object
ChartBaseView
PieChartView

Implements

DevExpress.XamarinForms.Charts.Internal.IChartElement
DevExpress.XamarinForms.Core.Internal.IBindingContextParent
See Also