Make Area Chart to PDF Sample
insert area chart to pdf in c# .net

C# code tutorial

PDF Chart PDF Creating & Inserting PDF to Image PDF Digital Signature PDF Extracting PDF Processing & Editing PDF Protecting PDF Barcode

Popular .NET SDK

Area chart creator coming with built-in area chart symbols and ready-made area chart templates, to make it easy for developers to create polygons based on the data.

PDF area chart is a a two-axis chart, which is similar to line chart with the area between the line and axis filled in. Area chart view is useful when you need to show trends for several series on the same diagram, and also show the relationship of the parts to the whole.

.NET PDF Area Chart maker can create area chart graphs with single or multiple data sets, as well as arrays with null values and array of arrays. Developers can create area charts and insert the diagrams to PDF pages using XsPDF chart designer in .NET C# language.

static void AddAreaChartToPDF()
    // Create a new PDF document.
    PdfDocument document = new PdfDocument();

    // Create a page.
    PdfPage page = document.AddPage();

    // Generate a 2d area chart graph
    Chart chart = AreaChart();

    // 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);

    // Render chart symbols into pdf page
    XGraphics g = XGraphics.FromPdfPage(page);

    // Save and show the document           

static Chart AreaChart()
    // Set chart type to Area2D
    Chart chart = new Chart(ChartType.Area2D);

    // Add first series of area chart with name and data
    Series series = chart.SeriesCollection.AddSeries();
    series.Add(new double[] { 31, 9, 15, 28, 13 });

    // Add second series of area chart with name and data
    series = chart.SeriesCollection.AddSeries();
    series.Add(new double[] { 22, 7, 12, 21, 12 });

    // Add third series of area chart with name and data
    series = chart.SeriesCollection.AddSeries();
    series.Add(new double[] { 16, 5, 3, 20, 11 });

    // 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.Top;

    return chart;

More Excel tutorial