Legend

Represents a Legend.

public class Legend
Public Class Legend

Inheritance: ObjectLegend

Licensing Info

This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples

The following example creates a date time area series chart and creates a legend with color property.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.PageElements.Charting
Imports ceTe.DynamicPDF.PageElements.Charting.Series
    
Module MyModule
    
    Sub Main()
    
        ' Create a PDF Document
        Dim MyDocument As Document = New Document()
    
        ' Create a Page and add it to the document
        Dim MyPage As Page = New Page()
        MyDocument.Pages.Add(MyPage)
    
        ' Create a chart
        Dim MyChart As Chart = New Chart(0, 0, 400, 200)
    
        ' Get the default plot area from the chart
        Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea
    
        ' Create header titles and add it to the chart
        Dim MyTitle1 As Title = New Title("Website Visitors")
        Dim MyTitle2 As Title = New Title("Year - 2007")
        MyChart.HeaderTitles.Add(MyTitle1)
        MyChart.HeaderTitles.Add(MyTitle2)
    
        ' Create a legend to the chart
        Dim MyLegend1 As Legend = MyChart.Legends.Add(2, 3, 10, 10)
        MyLegend1.BackgroundColor = RgbColor.Pink
    
        ' Create date time area series and add values to it
        Dim MyAreaSeries1 As DateTimeAreaSeries = New DateTimeAreaSeries("Website A")
        MyAreaSeries1.Values.Add(5, New DateTime(2007, 1, 1))
        MyAreaSeries1.Values.Add(7, New DateTime(2007, 2, 1))
        MyAreaSeries1.Values.Add(9, New DateTime(2007, 3, 1))
        MyAreaSeries1.Values.Add(6, New DateTime(2007, 4, 1))
        Dim MyAreaSeries2 As DateTimeAreaSeries = New DateTimeAreaSeries("Website B")
        MyAreaSeries2.Values.Add(4, New DateTime(2007, 1, 1))
        MyAreaSeries2.Values.Add(2, New DateTime(2007, 2, 1))
        MyAreaSeries2.Values.Add(5, New DateTime(2007, 3, 1))
        MyAreaSeries2.Values.Add(8, New DateTime(2007, 4, 1))
        Dim MyAreaSeries3 As DateTimeAreaSeries = New DateTimeAreaSeries("Website C")
        MyAreaSeries3.Values.Add(2, New DateTime(2007, 1, 1))
        MyAreaSeries3.Values.Add(4, New DateTime(2007, 2, 1))
        MyAreaSeries3.Values.Add(6, New DateTime(2007, 3, 1))
        MyAreaSeries3.Values.Add(9, New DateTime(2007, 4, 1))
    
        'Add date time area series to the plot area
        MyPlotArea.Series.Add(MyAreaSeries1)
        MyPlotArea.Series.Add(MyAreaSeries2)
        MyPlotArea.Series.Add(MyAreaSeries3)
    
        ' Create a title and add it to yAxis
        Dim MyTitle3 As Title = New Title("Viewers (in millions)")
        MyAreaSeries1.YAxis.Titles.Add(MyTitle3)
    
        ' Set label  format for the axis labels
        MyAreaSeries1.XAxis.LabelFormat = "MMM"
    
        'Add the chart to the page
        MyPage.Elements.Add(MyChart)
    
        ' Save the PDF
        MyDocument.Draw("C:\MyDocument.pdf")
    
    End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.PageElements.Charting;
using ceTe.DynamicPDF.PageElements.Charting.Series;

public class Example
{
    public static void CreatePDF(string outputPath)
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a Page and add it to the document
        Page page = new Page();
        document.Pages.Add(page);

        // Create a chart
        Chart chart = new Chart(0, 0, 400, 200);

        // Get the default plot area from the chart
        PlotArea plotArea = chart.PrimaryPlotArea;

        // Create header titles and add it to the chart
        Title title1 = new Title("Website Visitors");
        Title title2 = new Title("Year - 2007");
        chart.HeaderTitles.Add(title1);
        chart.HeaderTitles.Add(title2);

        // Create a legend to the chart
        Legend legend1 = chart.Legends.Add(2, 3, 10, 10);
        legend1.BackgroundColor = RgbColor.Pink;

        // Create date time area series and add values to it
        DateTimeAreaSeries areaSeries1 = new DateTimeAreaSeries("Website A");
        areaSeries1.Values.Add(5, new DateTime(2007, 1, 1));
        areaSeries1.Values.Add(7, new DateTime(2007, 2, 1));
        areaSeries1.Values.Add(9, new DateTime(2007, 3, 1));
        areaSeries1.Values.Add(6, new DateTime(2007, 4, 1));
        DateTimeAreaSeries areaSeries2 = new DateTimeAreaSeries("Website B");
        areaSeries2.Values.Add(4, new DateTime(2007, 1, 1));
        areaSeries2.Values.Add(2, new DateTime(2007, 2, 1));
        areaSeries2.Values.Add(5, new DateTime(2007, 3, 1));
        areaSeries2.Values.Add(8, new DateTime(2007, 4, 1));
        DateTimeAreaSeries areaSeries3 = new DateTimeAreaSeries("Website C");
        areaSeries3.Values.Add(2, new DateTime(2007, 1, 1));
        areaSeries3.Values.Add(4, new DateTime(2007, 2, 1));
        areaSeries3.Values.Add(6, new DateTime(2007, 3, 1));
        areaSeries3.Values.Add(9, new DateTime(2007, 4, 1));

        //Add date time area series to the plot area
        plotArea.Series.Add(areaSeries1);
        plotArea.Series.Add(areaSeries2);
        plotArea.Series.Add(areaSeries3);

        // Create a title and add it to yAxis
        Title title3 = new Title("Viewers (in millions)");
        areaSeries1.YAxis.Titles.Add(title3);

        // Set label  format for the axis labels
        areaSeries1.XAxis.LabelFormat = "MMM";

        //Add the chart to the page
        page.Elements.Add(chart);

        // Save the PDF
        document.Draw(outputPath);
    }
}

Remarks

A Chart can have multiple Legends. Each Chart has one default Legend called DefaultLegend. If the Chart's Auto Layout property is true, the Legends will occupy 35% of the Chart width

Properties

AlignGets or sets the legend labels text alignment.
BackgroundColorGets or sets the BackgroundColor of the Legend.
BorderColorGets or sets the BorderColor of the Legend.
BorderStyleGets or sets the LineStyle of the Legend.
BorderWidthGets or sets the LineWidth of the Legend.
BottomPaddingGets or sets the BottomPadding of the Legend.
FontGets or sets the Font of the Legend.
FontSizeGets or sets the FontSize of the Legend.
HeightGets or sets the height of the Legend.
LabelSpacingGets or sets the LabelSpacing of the Legend.
LeftPaddingGets or sets the LeftPadding of the Legend.
LegendLabelListGets or sets the LegendLabelList from the Legend.
RequiredHeightGets the RequiredHeight to draw the Legend.
RequiredWidthGets the RequiredWidth to draw the Legend.
RightPaddingGets or sets the RightPadding of the Legend.
SymbolSpacingGets or sets the SymbolSpacing of the Legend.
TextColorGets or sets the TextColor of the Legend.
TopPaddingGets or sets the TopPadding of the Legend.
VisibleGets or sets the visible property of the Legend.
WidthGets or sets the width of the Legend.
XGets or sets the x position of the Legend.
YGets or sets the y position of the Legend.

Methods

Equals(Object)Determines whether the specified Object is equal to the current Object .
(Inherited from Object)
GetHashCode()Serves as a hash function for a particular type.
(Inherited from Object)
GetType()Gets the Type of the current instance.
(Inherited from Object)
ToString()Returns a String that represents the current Object .
(Inherited from Object)

See Also

ceTe.DynamicPDF.PageElements.Charting

In this topic