DXPieChart Class
The view that displays data in a Pie (Circular) chart.
Namespace: DevExpress.Xamarin.iOS.Charts
Assembly: DevExpress.Xamarin.iOS.Charts.dll
NuGet Package: DevExpress.XamarinForms.Charts
Declaration
public class DXPieChart :
DXChartBase
Remarks
The image below represents a Pie chart and highlights its components:
How to: modify chart series
The Pie Chart displays data Series provide. Series that inherit the DXPieSeries class are compatible with the Pie Chart.
The following code snippet shows how to add a series to a chart:
this.pieChart.AddSeries(new DXDonutSeries {
Data = LandAreaListDataAdapter(new List<LandAreaItem> {
new LandAreaItem("Russia", 17.098),
new LandAreaItem("Canada", 9.985),
new LandAreaItem("China", 9.597),
new LandAreaItem("USA", 9.525),
new LandAreaItem("Brazil", 8.515)
})
});
// ...
class LandAreaListDataAdapter : DXPieSeriesData {
IReadOnlyList<LandAreaItem> landAreas;
public CountryAreaData(IReadOnlyList<LandAreaItem> landAreas) {
this.landAreas = landAreas;
}
public override int DataCount { get => landAreas.Count; }
public override getLabelByIndex(int index) => landAreas[index].CountryName;
public func getValueByIndex(int index) => landAreas[index].LandArea;
}
class LandAreaItem {
public string CountryName { get; }
public double LandArea { get; }
public LandAreaItem(string countryName, double landArea) {
CountryName = countryName;
LandArea = landArea;
}
}
The following table contains methods allowing you to obtain, add or remove series of the chart:
Property or Method | Description |
---|---|
Returns all series the Pie chart displays. | |
Adds the specified series to the Pie Chart to display. | |
Removes the specified series from the Pie Chart. | |
Removes a series with the specified index from the Pie chart. |
Refer to the Series guide to learn more about chart series.
How to: configure a chart legend
The DXLegend identifies a Pie series’s points in the chart. The following example demonstrates how to position the legend above the series:
this.pieChart.Legend = new DXLegend {
VerticalPosition = DXLegendVerticalPosition.TopOutside,
HorizontalPosition = DXLegendHorizontalPosition.Center,
Orientation = DXLegendOrientation.TopToBottom
}
The table below contains the main symbols that manage the legend:
Method | Description |
---|---|
Gets or sets the chart’s legend. | |
A chart element that displays series and series points’ designations. |
Refer to the Legend guide for more information about legend configuration.
How to: change chart appearance
The DXPieChartStyle object manages the Pie Chart’s appearance. The following image highlights the chart style’s parameters:
The code below configures the Pie Chart as in the image above:
// All sizes are in screen points.
self.pieChart.style = new DXPieChartStyle {
BorderColor = UIColor.FromWhiteAlpha(0.28627f, 1.0f),
BorderThickness = 2,
BackgroundColor = UIColor.FromWhiteAlpha(0.16471f, 1.0f),
SeriesIndent = 10,
Palette = new DXPalette {
Colors = new UIColor[] {
UIColor.FromRGBA(0.45882f, 0.75294f, 0.60000f, 1.0f),
UIColor.FromRGBA(0.67451f, 0.76471f, 0.44313f, 1.0f),
UIColor.FromRGBA(0.21569f, 0.54117f, 0.54117f, 1.0f),
UIColor.FromRGBA(0.37255f, 0.63529f, 0.41569f, 1.0f),
UIColor.FromRGBA(0.02353f, 0.28627f, 0.43922f, 1.0f)
}
}
};
The following symbols allow you to configure the chart style:
Symbols | Description |
---|---|
Gets or sets the appearance style settings. | |
The Pie Chart’s appearance settings storage. |