[]
Pie charts, the most common tools used for data visualization, are circular graphs that display the proportionate contribution of each category, which is represented by a pie or a slice. The magnitude of the dependent variable is proportional to the angle of the slice. These charts can be used for plotting just one series with non-zero and positive values.
DsExcel supports the following types of pie charts.
Chart Type | Chart Snapshot | Use Case |
---|---|---|
Pie |
Pie chart | Pie chart is used to display a single data series in a circle-type structure, with each sector representing a different category. |
Pie3D |
Pie3D chart | Pie3D chart is used to display the chart demonstration in 3D which is a modification of 2DPie chart in terms of appearance. |
PieExploded |
PieExploded chart | PieExploded chart is used to pull all of the slices out of a pie chart and view the sectors separately in pieces. |
PieExploded3D |
| PieExploded 3D chart is used display the chart demonstration in 3D which is a modification of 2DPieExploded chart. |
PieOfPie |
PieOfPie chart | PieofPie chart is used to separate the slices from the main pie chart and display them in an additional pie chart. |
BarOfPie |
BarOfPie chart | BarofPie chart is used to separate the slices from the main pie chart and display them in an additional stacked bar chart. |
Doughnut |
Doughnut chart | Doughnut chart is used to display multiple data series concurrently, with each ring depicting a single data series. |
DoughnutExploded |
DoughnutExploded chart | DoughnutExploded is used to pull all slices out of a DoughnutExploded chart and view the sectors separately in pieces. |
Refer to the following code to add Doughnut Exploded chart:
private static void PieCharts() {
// Initialize workbook
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.getWorksheets().get(0);
// Prepare data for chart
worksheet.getRange("A1:D4")
.setValue(new Object[][] {
{ null, "Q1", "Q2", "Q3" },
{ "Mobile Phones", 1330, 2345, 3493 },
{ "Laptops", 2032, 3632, 2197 },
{ "Tablets", 6233, 3270, 2030 } });
worksheet.getRange("A:D").getColumns().autoFit();
// Add Pie Chart
IShape areaChartShape = worksheet.getShapes().addChart(ChartType.Pie3D, 250, 20, 360, 230);
// Adding series to SeriesCollection
areaChartShape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D4"), RowCol.Columns, true, true);
// Configure Chart Title
areaChartShape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs()
.add("Annual Sales Record");
// Saving workbook to Xlsx
workbook.save("22-PieChart.xlsx", SaveFileFormat.Xlsx);