![]() |
Contents page Previous | Next |
See the coded example, Legend control, in the Visual Basic 5 & 6 demos folder for a working example of some of the techniques outlined in this Tutorial.
Legend parameters are accessible via the Chart Editor, Chart tab, Legend page.
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 are 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 Legends
TChart1.Legend.LegendStyle = lsLastValues 'Puts the last value of each Series in the Legend box
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 Border Editor window where you can make the lines between Legend entries Visible and change their Color, Style and Width.
Visible
This Visible checkbox enables/disables the display of the entire Legend.
Inverted
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
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.
Margin
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.
Custom
This check box will disable the Resize Chart property and will enable you to position the Legend in pixels anywhere on the Chart Canvas.
Visible
Use the Visible property to show or hide the color rectangles (symbols).
Width
Set Width property to define the width of the Legend symbols.
Width Units
Use the WidthUnits property to define how the width must be interpreted.
Position
Use the Position property to set the position of the color rectangles.
Continuous
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.
Squared
Use the squared property to make the legend color rectangles square.
Default border and Border...
Use these properties to override the default border of the legend symbols with your own customised one.
Options
Here you can add the text you wish to use for the Legend Title and align the the text within the Title frame. Use the Visible checkbox to Hide/Unhide the Title.
Format
Use the properties to change the color, pattern and transparency of the Title area background
Border
Mixing Bevel and Frame properties and manipulating Width gives almost any combination of 3D effects. By checking Round Frame and selecting the radius size will give various rounded corners to the Title area.
Text
Use the many properties related to the Title Text to personalize the Font and related effects.
Gradient
Use the Visible property to show or hide the Title area background color gradient. An almost infinite number of gradients can be achieved from combining different gradient styles, colours, directions and sub-gradients.
Shadow
Use the Shadow properties to create a shadow effect for the Title area.
Emboss
Similar to the Shadow properties, you can use the Emboss properties to create a embossed effect for the Title area.
Picture
You can add an image to the Title area background and then modify it in many ways using the different Filters, Style and position properties.
Color
The color property sets the color for the Legend canvas.
Pattern
Sets the pattern for the Legend canvas.
Transparent
Makes the legend canvas transparent leaving just the Legend text and symbols on display.
Transparency
Sets the level of transparency for the legend canvas.
Bevel
Use the Bevel property to define the Legend's bevel.
Frame
Sets Legend Frame properties: Visible, Style, Color and Width.
Size
Sets the size of the Legend's bevel.
Round Frame
Rounds the corners of the Legend Frame.
Legend events offer the option to completely control and define the Legend appearance and content.
The Legend outer rectangle, permits changes to the overall size and position of the Legend box. Use in conjunction with OnGetLegendPos to reposition the Chart Legend and contents.
e.g.Private Sub TChart1_OnGetLegendRect(Left As Long, Top As Long, Right As Long, Bottom As Long) Left = Left - 100 Right = Right - 100 End Sub
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 Sub TChart1_OnGetLegendPos(ByVal Index As Long, X As Long, Y As Long, XColor As Long) X = X - 100 End Sub
Modifies the text of the Legend contents.
Private Sub TChart1_OnGetLegendText(ByVal LegendStyle As Long, ByVal ValueIndex As Long, LegendText As String) LegendText = LegendText + Str$(Index) 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.
![]() |
![]() |