From Steema Software Reference Wiki
Revision as of 14:36, 17 October 2014 by Clive (Talk | contribs)

Jump to: navigation, search

Net iphone.png

Contents page
Previous | Next

Tutorial 5 - Legend design

Legend control

Legend parameters. See Legend class help for more information


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. If you change the Legend Style to display values and there is more than one Series in your Chart, TeeChart NET for Android will display the values of the first Series. You may modify the display using custom options. See Customising Legends

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

tChart1.Legend.LegendStyle = 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 can be made visible or not and also be modified by changing their Color, Style and Width.


This Visible property 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.



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 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 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.


By disabling the Resize Chart property you will be able to position the Legend in pixels anywhere on  the Chart Canvas.



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.



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.


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


Use this page to draw a gradient onto the legend canvas and change it's direction and colours. ===Shadow===Sets the colour, size, pattern and transparency of the Legend's shadow.


Sets the colour, size and style of the Legend 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);  

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;

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();}

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-2014 Steema Software SL. All rights reserved.