This C# tutorial demonstrates how to create the Microsoft Polar Chart (both 2D and 3D Polar Chart), and insert the MS Polar Chart as image to PDF Page.
The following C# .NET demo code shows how to create and save Microsoft Polar Chart to PDF document programmatically.
Please note, before developers using the chart making code, the MS Chart Control should be referred to your .NET application:
- System.Windows.Forms.DataVisualization.Charting (for .NET WinForms project)
- System.Web.UI.DataVisualization.Charting (for ASP.NET application)
Generate and save Microsoft 2D Polar Chart to PDF in C# code.
public static void InsertMSChartToPDF() { // Create a new PDF document. PdfDocument document = new PdfDocument(); // Create an empty page in this document. PdfPage page = document.AddPage(); // Obtain an XGraphics object to render to XGraphics g = XGraphics.FromPdfPage(page); // Create polar chart stream object Stream chartStream = CreateMSPolarChart(); // Convert chart stream to XImage object XImage chartImage = XImage.FromStream(chartStream); // Insert the chart image to pdf page in any position g.DrawImage(chartImage, 50, 50); // Save and show the document document.Save("MSPolarChart.pdf"); Process.Start("MSPolarChart.pdf"); } public static Stream CreateMSPolarChart() { // Create ms chart object Chart chart = new Chart(); ChartArea chartArea = new ChartArea(); Series series1 = new Series(); Series series2 = new Series(); // Set series1 with width, maker, color, chart type and name series1.BorderColor = Color.FromArgb(180, 26, 59, 105); series1.BorderWidth = 3; series1.ChartType = SeriesChartType.Polar; series1.MarkerBorderColor = Color.FromArgb(64, 64, 64); series1.MarkerColor = Color.LightSkyBlue; series1.MarkerSize = 7; series1.Name = "Series1"; // Set series2 with width, maker, color, chart type and name series2.BorderColor = Color.FromArgb(180, 26, 59, 105); series2.BorderWidth = 3; series2.ChartType = SeriesChartType.Polar; series2.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); series2.MarkerColor = System.Drawing.Color.Gold; series2.MarkerSize = 7; series2.Name = "Series2"; // Bind series to chart chart.Series.Add(series1); chart.Series.Add(series2); // Fill series data for (double angle = 0.0; angle <= 360.0; angle += 10.0) { double yValue = (1.0 + Math.Sin(angle / 180.0 * Math.PI)) * 10.0; chart.Series["Series1"].Points.AddXY(angle + 90.0, yValue); chart.Series["Series2"].Points.AddXY(angle + 270.0, yValue); } // Set chart 3D style chartArea.Area3DStyle.Enable3D = false; // Bind chart area to chart object chart.ChartAreas.Add(chartArea); // Modify chart size chart.Size = new Size(400, 300); // Render chart graphics to stream MemoryStream ms = new MemoryStream(); chart.SaveImage(ms, ChartImageFormat.Png); return ms; }
Make and insert MS 3D Polar Chart to PDF in C# code.
All the step and code are the same as above, only need change the chartArea.Area3DStyle.Enable3D = false; in the "CreateMSPolarChart()" to the C# code below.
chartArea.Area3DStyle.Enable3D = true; chartArea.Area3DStyle.Inclination = 15; chartArea.Area3DStyle.IsRightAngleAxes = false; chartArea.Area3DStyle.Perspective = 10; chartArea.Area3DStyle.Rotation = 10; chartArea.BackColor = Color.WhiteSmoke;
More MS Chart to PDF tutorial
- Creating MS Polar graphs to PDF using .NET C# and XsPDF Library
- Save MS Point chart to PDF in Visual Studio .NET framework
- How to use XsPDF Library for .NET to convert Microsoft Spline Area diagram to PDF page in Visual C#
- Generate Microsoft Range Bar graphs to PDF in C#
- How to insert MS Range chart to PDF document in ASP.NET web application using Visual Studio .NET framework
- How to use XsPDF SDK for .NET to create MS Pie chart to PDF page in C#
- How to insert MS Bar chart to PDF document in ASP.NET using Visual C#
- MS Stacked Bar diagram painting to PDF in Visual C# is quite easy and quick using XsPDF DLL for .NET
- Add MS Bubble graphs to PDF in CSharp .NET
- Convert MS Stacked Area graphs to PDF in .NET
- .NET C# online sample for converting Microsoft 100% Stacked Bar chart to PDF file
- MS Stacked100 Column diagram generation to PDF in CSharp .NET is quite easy and quick using XsPDF Component for .NET
- MS Doughnut chart generating to PDF in CSharp .NET is quite easy and quick using XsPDF source code for .NET
- Saving Microsoft Stacked Column chart to PDF using C#.NET and XsPDF SDK
- How to create Microsoft Line graphing to PDF document in Azure cloud service using .NET