We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

pie chart issue

I have the following code meant to to create a pie chart.  There are 2 issues.  The first is getting the legend displayed properly and the 2nd is that the chart does not display properly

IWorksheet sheet10 = workbook.Worksheets[9];
sheet10.Range["A1"].Text = "How do ideas/opportunites get shared within the company.";
sheet10.Range["A1"].CellStyle.Font.Bold = true;
sheet10.Range["A1"].CellStyle.Font.Size = 18;
RadioButtonAnswers rba = new RadioButtonAnswers();
rba.SurveyNumber = SurveyNumber;
rba.GroupNumber = 10;
IList<GetRadioAnswerOccurances_Result> IdeasRadio = rba.RadioAnswers();
sheet10.ImportData(IdeasRadio, 3, 1, true);
IChartShape chart10 = sheet10.Charts.Add();
chart10.ChartType = ExcelChartType.Pie;
chartplacement = "A3:B7";     
chart10.DataRange = sheet10.Range[chartplacement];
chart10.Legend.Position = ExcelLegendPosition.Bottom;
chart10.Series[0].DataPoints.DefaultDataPoint.DataLabels.Size = 8;
chart10.TopRow = 3;
chart10.BottomRow = 25;
chart10.LeftColumn = 1;
chart10.RightColumn = 15;

I have tried as both A3:B7 and A4:B7 trying to get the legend correctly displayed
when finished it looks like what is shown in the excel file instead of what you see in the jpg image

note this is dynamic data  and the only time the data will look like this is during this test otherwise it will be totally different and with totally different numbers so filling in data at design time is NOT an option.   

Attachment: pieChart_fa04053d.zip

3 Replies

SS Sridhar Sukumar Syncfusion Team August 15, 2017 09:54 AM UTC

Hi Miranda,  
Thank you for contacting Syncfusion support. 
You can achieve your requirement by setting Chart.IsSeriesInRows property as false. Please refer the following code example to achieve this. 
Code snippet: 
Chart.IsSeriesInRows = false; 
We have prepared a sample to achieve your requirement in XlsIO which can be downloaded from the following link. 
Sample link: 

MJ Miranda Johnson August 15, 2017 06:56 PM UTC

Thank you.  That worked great.  :)  


SS Sridhar Sukumar Syncfusion Team August 16, 2017 10:40 AM UTC

Hi Miranda, 
We are glad that the issue is resolved at your end. Please let us know if you need any further assistance. 

Live Chat Icon For mobile
Up arrow icon