PDF stacked column charts plot datasets on top of each other, instead of the clustered side-by-side placement adopted by multi-series charts. Stacked column charts in PDF pages help in displaying the cumulative magnitude of two or more data series. The stacked charts help in comparison of sum, but is not suited for comparison of the constituents of each column against each other.
.NET PDF Stacked Column Chart Maker is one of the drawing functions in XsPDF chart creator. It allows developers to make stacked column chart and insert the graphs and diagram into PDF pages from multiple Visual .NET applications, such as C#, VB.NET, ASP.NET and WinForms. This tutorial article mainly demonstrates the stacked column chart making on PDF document pages in an easy way.
static void AddStackedColumnChartToPDF() { // Create a new PDF document. PdfDocument document = new PdfDocument(); // Create a page. PdfPage page = document.AddPage(); // Generate a 2d stacked column chart graph Chart chart = ColumnStackedChart(); // Create a chart frame, set chart location and size ChartFrame chartFrame = new ChartFrame(); chartFrame.Location = new XPoint(30, 30); chartFrame.Size = new XSize(500, 600); chartFrame.Add(chart); // Render chart symbols into pdf page XGraphics g = XGraphics.FromPdfPage(page); chartFrame.Draw(g); // Save and show the document document.Save("StactedColumnChart.pdf"); Process.Start("StactedColumnChart.pdf"); } static Chart ColumnStackedChart() { // Set chart type to ColumnStacked2D Chart chart = new Chart(ChartType.ColumnStacked2D); // Add first series of stacked column chart with name and data Series series = chart.SeriesCollection.AddSeries(); series.Name = "Series 1"; series.Add(new double[] { 1, 5, -3, 20, 11 }); // Add second series of stacked column chart with name and data series = chart.SeriesCollection.AddSeries(); series.Name = "Series 2"; series.Add(new double[] { 22, 4, 12, 8, 12 }); // Add third series of stacked column chart with name and data series = chart.SeriesCollection.AddSeries(); series.Name = "Series 3"; series.Add(new double[] { 12, 14, 2, 18, 1 }); // Add fourth series of stacked column chart with name and data series = chart.SeriesCollection.AddSeries(); series.Name = "Series 4"; series.Add(new double[] { 17, 13, 10, 9, 15 }); // Set X axes chart.XAxis.TickLabels.Format = "00"; chart.XAxis.MajorTickMark = TickMarkType.Outside; chart.XAxis.Title.Caption = "X-Axis"; // Set Y axes chart.YAxis.MajorTickMark = TickMarkType.Outside; chart.YAxis.HasMajorGridlines = true; // Set plot area (chart diagram) chart.PlotArea.LineFormat.Color = XColors.DarkGray; chart.PlotArea.LineFormat.Width = 1; chart.PlotArea.LineFormat.Visible = true; // Set legend chart.Legend.Docking = DockingType.Right; chart.DataLabel.Type = DataLabelType.Value; chart.DataLabel.Position = DataLabelPosition.Center; return chart; }