[]
Pie charts are one of the most common charts used for data visualization. They are circular graphs that display the proportionate contribution of different categories, which is represented by a slice of a pie. The size of each slice corresponds to the magnitude of the dependent variable, making it proportional to the angle of the slice. These charts are suitable for plotting just one series with non-zero and positive values.
Spread Windows Forms supports the following types of pie charts.
Sample Image | Description |
|---|---|
| ChartType.Pie Represents a common pie chart. It is used to display a single data series in a circle-type structure, with each sector representing a different category. |
| ChartType.PieOfPie Represents a pie of pie chart. It is used to separate the slices from the main pie chart and display them in an additional pie chart. |
| ChartType.BarOfPie Represents a bar of pie chart. It is used to separate the slices from the main pie chart and display them in an additional stacked bar chart. |
Refer to the following example code to add a pie chart.
C#
// Enable enhanced shape and chart engines.
fpSpread1.Features.EnhancedShapeEngine = true;
fpSpread1.Features.EnhancedChartEngine = true;
// Add data.
object[,] dataArray = {
{"", "Chrome", "Firefox", "IE", "Safari", "Edge", "Opera", "Other"},
{2014, 0.4966, 0.1801, 0.2455, 0.0470, 0.0898, 0.0150, 0.0158},
{2015, 0.5689, 0.1560, 0.1652, 0.0529, 0.0158, 0.0220, 0.0192},
{2016, 0.6230, 0.1531, 0.1073, 0.0464, 0.0311, 0.0166, 0.0225},
{2017, 0.6360, 0.1304, 0.0834, 0.0589, 0.0443, 0.0223, 0.0246}
};
for (int i = 0; i < dataArray.GetLength(0); i++)
{
for (int j = 0; j < dataArray.GetLength(1); j++)
{
fpSpread1.AsWorkbook().ActiveSheet.Cells[i, j].Value = dataArray[i, j];
}
}
// Pie chart.
fpSpread1.AsWorkbook().ActiveSheet.Cells["A1:H5"].Select();
fpSpread1.AsWorkbook().ActiveSheet.Shapes.AddChart(GrapeCity.Spreadsheet.Charts.ChartType.PieOfPie, 100, 150, 400, 300, false);VB
' Enable enhanced shape and chart engines.
fpSpread1.Features.EnhancedShapeEngine = True
fpSpread1.Features.EnhancedChartEngine = True
' Add data.
Dim dataArray As Object(,) = {
{"", "Chrome", "Firefox", "IE", "Safari", "Edge", "Opera", "Other"},
{2014, 0.4966, 0.1801, 0.2455, 0.047, 0.0898, 0.015, 0.0158},
{2015, 0.5689, 0.156, 0.1652, 0.0529, 0.0158, 0.022, 0.0192},
{2016, 0.623, 0.1531, 0.1073, 0.0464, 0.0311, 0.0166, 0.0225},
{2017, 0.636, 0.1304, 0.0834, 0.0589, 0.0443, 0.0223, 0.0246}
}
For i As Integer = 0 To dataArray.GetLength(0) - 1
For j As Integer = 0 To dataArray.GetLength(1) - 1
fpSpread1.AsWorkbook().ActiveSheet.Cells(i, j).Value = dataArray(i, j)
Next
Next
' Pie chart.
fpSpread1.AsWorkbook().ActiveSheet.Cells("A1:H5").Select()
fpSpread1.AsWorkbook().ActiveSheet.Shapes.AddChart(GrapeCity.Spreadsheet.Charts.ChartType.PieOfPie, 100, 150, 400, 300, False)