C# .NET - Change the colors for the slices of a piechart in C#

Asked By Ramesh Korada on 30-Sep-16 05:59 AM
objSlide = objSlides.Add(2, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
objTextRng.Text = "My Chart";
objTextRng.Font.Name = "Comic Sans MS";
objTextRng.Font.Size = 48;
objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320,"MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "",MsoTriState.msoFalse).OLEFormat.Object;
objChart.ChartType = Graph.XlChartType.xl3DPie;
Graph.DataSheet dataSheet = objChart.Application.DataSheet;
dataSheet.Cells[1, 2] = "1";
dataSheet.Cells[1, 3] = "2";
dataSheet.Cells[1, 4] = "3";
dataSheet.Cells[1, 5] = "4";
dataSheet.Cells[2, 2] = "10";
dataSheet.Cells[2, 3] = "20";
dataSheet.Cells[2, 4] = "30";
dataSheet.Cells[2, 5] = "40";
objChart.Application.Update();
objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom;
objChart.HasTitle = true;
objChart.ChartTitle.Text = "Here it is...";