3D Pie chart format

Rikasa
Updated on Apr 19, 2018 04:42 AM
Hi,

We are using syncfusion to generate the report. 

Currently I am generating Word document with '3D pie chart'. 

code :- "chartGraphic.ChartType = OfficeChartType.Pie_Exploded_3D"

Report  generation is working perfectly.  But data is not properly visible.

So I need to format pie chart style, such as change series background color and 3D rotation. Please give me solution.

Actual result :-                                                        Expected result:-  Including series color and chart rotation changes

           

Thanks.

Regards,
Rikasa

5 Replies

MJ Mohanaselvam Jothi Syncfusion Team April 20, 2018 05:08 PM UTC

Hi Rikasa,

Thank you for contacting Syncfusion support.

To achieve your requirement using DocIO, we suggest you to set rotation properties for the chart and then set colors for each data points in the chart series in the Word document.

Please refer the below highlighted code snippets to meet your requirement using DocIO:
 
//Creates a new Word document 
WordDocument document = new WordDocument(); 
//This method adds one section and one paragraph to the Word document. 
document.EnsureMinimal(); 
//Creates and Appends chart to the paragraph 
WChart chart = document.LastParagraph.AppendChart(446, 270); 
//Sets chart type 
chart.ChartType = OfficeChartType.Pie_Exploded_3D; 
IOfficeChartSerie pieSeries = chart.Series.Add(); 
chart.ChartTitle = "Graphic Results"; 
 
//Set rotation value for x-axis of 3D chart. 
chart.Rotation= 253; 
//Set rotation value for y-axis of 3D chart. 
chart.Elevation = 20; 
//SetpPerspective value for 3D chart. 
chart.Perspective = 30; 
//Set false for chart axes are at right angles. 
chart.RightAngleAxes = false; 
 
//Sets data for chart 
chart.ChartData.SetValue(1, 1, ""); 
chart.ChartData.SetValue(1, 2, "Graphic Results"); 
chart.ChartData.SetValue(2, 1, "Phyllis Lapin"); 
chart.ChartData.SetValue(2, 2, 31); 
chart.ChartData.SetValue(3, 1, "Stanley Hudson"); 
chart.ChartData.SetValue(3, 2, 23); 
chart.ChartData.SetValue(4, 1, "Bernard Shah"); 
chart.ChartData.SetValue(4, 2, 16); 
chart.ChartData.SetValue(5, 1, "Patricia Lincoln"); 
chart.ChartData.SetValue(5, 2, 15); 
chart.ChartData.SetValue(6, 1, "Lincoln"); 
chart.ChartData.SetValue(6, 2, 15); 
//Creates a new chart series      
pieSeries.Values = chart.ChartData[2, 2, 6, 2]; 
//Sets data label 
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsPercentage = true; 
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside; 
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None; 
chart.HasLegend = false; 
 
//Set forecolor for each data points. 
chart.Series[0].DataPoints[0].DataFormat.Fill.ForeColor = Color.FromArgb(255,0,0); 
chart.Series[0].DataPoints[1].DataFormat.Fill.ForeColor = Color.FromArgb(128, 128, 128); 
chart.Series[0].DataPoints[2].DataFormat.Fill.ForeColor = Color.FromArgb(108, 150, 6); 
chart.Series[0].DataPoints[3].DataFormat.Fill.ForeColor = Color.FromArgb(255,255,0); 
chart.Series[0].DataPoints[4].DataFormat.Fill.ForeColor = Color.FromArgb(33, 178, 82); 
 
//Saves the document 
document.Save("Sample.docx", FormatType.Docx); 
//Closes the document 
document.Close(); 


Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 



RI Rikasa April 23, 2018 05:07 AM UTC

Hi Jothi,

Thank you for your updated answer.

I followed your code. Set colors to data points are working fine. Thanks for your great help.

But When I debug the code, set rotation property is giving exception. Please give me solution for this.

Exception


Thanks.

Regards,
Rikasa


MJ Mohanaselvam Jothi Syncfusion Team April 24, 2018 07:16 AM UTC

Hi Rikasa,

Thank you for your update.

We have tried to reproduce the reported problem when applying rotation for 3D pie chart in the Word document using DocIO, but it works properly at our end. For your reference we have prepared a sample application which used at our end to reproduce the issue.

Please find the sample from the below link:
http://www.syncfusion.com/downloads/support/forum/137130/ze/Generate_Word1320386513.zip

We suspect that the reported problem might be due to the code snippets used at your end. So, could you please provide us the modified sample of above along with the code snippets and the product version details used at your end. Thereby we will analyze further and provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Mohanaselvam J




RI Rikasa April 24, 2018 09:29 AM UTC

Hi Jothi,

I looked sample project which you have sent. I found the issue . 

Thank you so much for your great help.

Issue was /'/Creating series' should be next to the '//set chart type'.

But I added '//creating series' code next to '//set data for chart'.

Now I changed the position and working fine.

Thanks again.

Regards,

Rikasa



MJ Mohanaselvam Jothi Syncfusion Team April 25, 2018 09:54 AM UTC

Hi Rikasa,

Thank you for your update.

We are glad that our solution has resolved your issue. Please get back to us if you need any other assistance.
We will be happy to assist you as always.


Regards,
Mohanaselvam J
 


Loader.
Up arrow icon