Xceed Chart for WinForms v4.4 Documentation
Welcome to Xceed Chart for WinForms v4.4 / User Guide / Legends / General

In This Topic
    General
    In This Topic

    Xceed Chart for WinForms provides an integrated legend that can display various types of information about the chart. The flexible design of the integrated legend helps you to customize the displayed data with ease. 

    The Legend object encapsulates the legend functionality. Legends are contained in the LegendCollection, accessible through the Legends property of the chart control:

    VB.NET  
    Dim legendsCollection As LegendCollection =   chartControl1.Legends
    
    C#  
    LegendCollection legendsCollection = chartControl1.Legends;
    

    By default there is only one chart and one legend associated with this chart. This is why it is safe to request a Legend object from the collection at startup:

    VB.NET  

    Dim legendsCollection As LegendCollection = chartControl1.Legends
    Dim legend As Legend = CType(legendsCollection(0), Legend)
    C#  
    LegendCollection legendsCollection = chartControl1.Legends;
    Legend legend = (Legend)legendsCollection[0];

    The legend in Xceed Chart consists of several components, as illustrated in the following diagram:

     

     

    The following table shows the same legend rendered without a backplane and grid: 

    Original legend Legend with Backplane Disabled Legend with Grid Disabled

    Legend Header and Footer

    The legend header and footer are represented by LegendText objects contained in Legend and accessible through the Header and Footer properties. Each LegendText object has a ChartText object controlling the header or footer font, size, etc. The Text property specifies the text displayed by the header or footer. The following code shows how to assign some text to legend header:

    VB.NET  

    legend.Header.Text = "Some legend header"
    legend.Header.TextProps.Font = New Font("Arial", 12)
    legend.Header.InflateHeight = 6
    legend.Header.InflateWidth = 6
    C#  
    Legend.Header.Text = "Some legend header";
    Legend.Header.TextProps.Font = new Font("Arial", 12);
    Legend.Header.InflateHeight = 6;
    Legend.Header.InflateWidth = 6;

    The InflateHeight and InflateWidth properties of LegendText allow you to increase the header or footer size in pixels. By default the header and footer texts are blank and the legend displays them.

    Legend Backplane

    The legend backplane is an instance of the Backplane object described in detail in the Backplanes topic.

    Legend Grid

    The legend grid visually separates the data items horizontally and vertically. The legend grid's properties are exposed through the HorizontalLinesProps, VerticalLinesProps, OutlineHorizontalLinesProps, and OutlineVerticalLinesProps properties of the LegendData object containing the legend's data items. The following example changes the horizontal grid lines to red and disables all other grid lines:

    VB.NET  

    legend.Data.HorizontalLinesProps.Color = Color.Red
    legend.Data.VerticalLinesProps.Width = 0
    legend.Data.OutlineVerticalLinesProps.Width = 0
    legend.Data.OutlineHorizontalLinesProps.Width = 0
    C#  
    legend.Data.HorizontalLinesProps.Color = Color.Red;
    legend.Data.VerticalLinesProps.Width = 0;
    legend.Data.OutlineVerticalLinesProps.Width = 0;
    legend.Data.OutlineHorizontalLinesProps.Width = 0;

    Related Examples

    Windows Forms: Legend\General 

    Web forms: Legend\General

    See Also

    Legend | LegendText | ChartText | Feeding Custom Data | Layout and Position