We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set 3D Rotation of Pie chart using C#.NET


I’m trying to replace a module that used the old ASPOSE.Charts with ASPOSE.Cells. I’m trying to make a Pie chart to resemble the old pie chart we used to have. However, the Pie3D chart is very flat, which makes it difficult to interpret. In Excel, you can set the 3D Rotation on the Y Axis to 45 degrees, so that the pie chart is more round. I’m struggling to find the method in Aspose.Cells that does the same thing.


Here is an example which creates 3D pie chart. Chart.Elevation can be used to rotate the chart on Y-Axis. Please give it a try and provide your feedback.

// Create a new Workbook.
Workbook workbook = new Workbook();

// Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];

// Set the name of worksheet
sheet.Name = "Data";

// Get the cells collection in the sheet.
Cells cells = workbook.Worksheets[0].Cells;

// Put some values into a cells of the Data sheet.

// Add a chart sheet.
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
sheet = workbook.Worksheets[sheetIndex];

// Set the name of worksheet
sheet.Name = "Chart";

// Create chart
int chartIndex = 0;
chartIndex = sheet.Charts.Add(ChartType.Pie3D, 5, 0, 25, 10);
Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];

// Set some properties of chart plot area.
// To set the fill color and make the border invisible.
chart.PlotArea.Area.ForegroundColor = Color.Coral;
chart.PlotArea.Area.FillFormat.SetTwoColorGradient(Color.Yellow, Color.White, Aspose.Cells.Drawing.GradientStyleType.Vertical, 2);
chart.PlotArea.Border.IsVisible = false;
chart.Elevation = 45;
// Set properties of chart title
chart.Title.Text = "Sales By Region";
chart.Title.Font.Color = Color.Blue;
chart.Title.Font.IsBold = true;
chart.Title.Font.Size = 12;

// Set properties of nseries
chart.NSeries.Add("Data!B2:B8", true);
chart.NSeries.CategoryData = "Data!A2:A8";
chart.NSeries.IsColorVaried = true;

// Set the DataLabels in the chart
Aspose.Cells.Charts.DataLabels datalabels;
for (int i = 0; i < chart.NSeries.Count; i++)
    datalabels = chart.NSeries[i].DataLabels;
    datalabels.Position = Aspose.Cells.Charts.LabelPositionType.InsideBase;
    datalabels.ShowCategoryName = true;
    datalabels.ShowValue = true;
    datalabels.ShowPercentage = false;
    datalabels.ShowLegendKey = false;


// Set the ChartArea.
Aspose.Cells.Charts.ChartArea chartarea = chart.ChartArea;
chartarea.Area.Formatting = Aspose.Cells.Charts.FormattingType.Custom;
chartarea.Area.FillFormat.Texture = Aspose.Cells.Drawing.TextureType.BlueTissuePaper;

// Set the Legend.
Aspose.Cells.Charts.Legend legend = chart.Legend;
legend.Position = Aspose.Cells.Charts.LegendPositionType.Left;
legend.Height = 100;
legend.Width = 130;
legend.Y = 1500;
legend.Font.IsBold = true;
legend.Border.Color = Color.Blue;
legend.Area.Formatting = Aspose.Cells.Charts.FormattingType.Custom;

// Set FillFormat.
Aspose.Cells.Drawing.FillFormat fillformat = legend.Area.FillFormat;
fillformat.Texture = Aspose.Cells.Drawing.TextureType.Bouquet;

// Save the excel file

Console.WriteLine("HowToCreatePieChart executed successfully.");

Ah, Perfect, thank you. That did the trick


Good to know that your issue is sorted out by the suggested line of code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.