From Steema Software Reference Wiki
Jump to: navigation, search


Contents page
Previous | Next

Tutorial5 - Legend design

Legend control

Legend parameters are accessible via the TeeChart Editor, Chart tab, Legend page:


Legend parameters. See Legend class help for more information

Style Tab

Legend Style 

Legend default Style "Automatic" will put Series point values in the Legend when there is only one Series in the Chart. When the Chart contains more than one Series, "automatic" will put Series names in the Legend. In the Editor use the Dropdown Combobox to obtain values other than the default. If you change the Legend Style to display values and there is more than one Series in your Chart, TeeChart Pro will display the values of the first Series. You may modify the display using custom options. See [#Customising Customising Legends]

Puts the last value of each Series in the Legend box:

tChart1.Legend.LegendStyle = LegendStyles.LastValues;

TChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.LastValues

Text Style 

See the TextStyle property for a list of possible Legend text styles.

Vertical Spacing 

Allows you to modify the spacing between Legend entries.  

Dividing Lines 

The Dividing Lines button gives access to a Pen Editor window where you can make the lines between Legend entries Visible and change their Color, Style and Width.


This Visible checkbox enables/disables the display of the entire Legend.


Inverting the Legend reverses the order of the Legend entries.

Check Boxes 

Changes the Legend Style to "Series Names" and displays a check box next to each series allowing it to be made  invisible or visible.

Font Series Color 

Changes the color of the font of the Legend text to the series color.

Position Tab



There are 4 positions available using the Alignment property, Top, Bottom, Left and Right. Right is the default  position. The default positioning of the Legend will always be outside the Chart. See the section about [#Customising Customising Legends] for more information about positioning Legends.

Resize Chart 

The Resize Chart property, when not enabled, will draw the legend within the Chart frame area. Whilst this may be satisfactory for some Legend positioning requirements, better control of Legend positioning in relation to the Chart frame  can be achieved by using the Legend Margin property.


Changing the Margin property value will move the Chart frame in relation to the Legend, NOT vice versa. Thus, making a  Margin value negative will move the Chart over the Legend (increasing the size of the Chart rectangle area). However, the  properties are not intended for repositioning of the Legend over the Chart, better to use the techniques outlined in [#Customising Customising Legends].

Position Offset % 

0% is defined as a horizontal Legend touching the right Chart canvas border and a vertical Legend touching  the top one. Legends are offset relative to these positions.


This check box will disable the Resize Chart property and will enable you to position the Legend in pixels anywhere on  the Chart Canvas.

Symbols Tab


Set Width property to define the width of the color rectangles (symbols).

Width Units 

Use the WidthUnits property to define how the width must be interpreted.


Use the Position property to set the position of the color rectangles.


Use Continous property to let the different legend color rectangles flow into each other. When set to True, the  color rectangles of the different items are drawn fixed to each other (no vertical spacing). When set to False, the color  rectangles are drawn as seperate rectangles.

Format Tab


The color property sets the color for the Legend canvas.


Sets Legend Frame properties: Visible, Style, Color and Width [Pen properties].


Sets the pattern for the Legend canvas: Solid, Hatch, Gradient, Image [Hatch Brush properties].

Round Frame 

Rounds the corners of the Legend Frame.


Makes the legend canvas transparent leaving just the Legend text and symbols on display.


Sets the % transparency of the Legend when Transparent is set to true.

Text Tab
This page gives access to properties which change the appearance of the Legend text's font, the font's fill properties [Hatch Brush properties] and shadow.

Gradient Tab
Use this page to draw a gradient onto the legend canvas and change it's direction and colours.

Shadow Tab
Sets the colour, size, pattern and transparency of the Legend's shadow.

Bevel Tab
Sets the colour, size and style of the Legend's inner and outer bevels.

Customising Legends

Legend events offer the option to completely control define the Legend appearance and content.

OnGetLegendRect event
The Legend outer rectangle, permits changes to the overall size and position of the Legend box. Use in conjunction with the OnGetLegendPos to reposition the Chart Legend and contents.

private void tChart1_GetLegendRect(object sender, Steema.TeeChart.TChart.GetLegendRectEventArgs e)
            e.Rectangle=new Rectangle(e.Rectangle.Left-100,e.Rectangle.Top,e.Rectangle.Width,e.Rectangle.Height);  

Private Sub TChart1_GetLegendRect(ByVal sender As Object, ByVal e As Steema.TeeChart.TChart.GetLegendRectEventArgs) Handles TChart1.GetLegendRect
        e.Rectangle = New Rectangle(e.Rectangle.Left - 100, e.Rectangle.Top, e.Rectangle.Width, e.Rectangle.Height)
End Sub

OnGetLegendPos event
Modifies the contents of the Legend. The following example could be used with the code above to move Legend contents to the new Legend rectangle.

private void tChart1_GetLegendPos(object sender, Steema.TeeChart.TChart.GetLegendPosEventArgs e)
            e.X = e.X-100;
            e.XColor = e.XColor-100;

Private Sub TChart1_GetLegendPos(ByVal sender As Object, ByVal e As Steema.TeeChart.TChart.GetLegendPosEventArgs) Handles TChart1.GetLegendPos
        e.X = e.X - 100
        e.XColor = e.XColor - 100
End Sub

OnGetLegendText event
Modifies the text of the Legend contents.

private void tChart1_GetLegendText(object sender, Steema.TeeChart.TChart.GetLegendTextEventArgs e)
            if(e.Index == 3)
            {e.Text = e.Text " Index no.:" e.Index.ToString();}

Private Sub TChart1_GetLegendText(ByVal sender As Object, ByVal e As Steema.TeeChart.TChart.GetLegendTextEventArgs) Handles TChart1.GetLegendText
        If e.Index = 3 Then
            e.Text = e.Text " Index no.:" e.Index.ToString
        End If
End Sub

When placing the Legend within the Chart rectangle area, bear in mind that the Legend paints before Series and Axes and will appear below either of those at any intersection point.



© 1998-2019 Steema Software SL. All rights reserved.