Difference between revisions of "AXTutorial5"

From Steema Software Reference Wiki
Jump to: navigation, search
(Created page with "<H2><A NAME="TeeChart_tutorial_5"></A>Tutorial 5 - Legend design</H2> <hr color="#DFDFBF"> <p> See the coded example,<b> Legend control</b>, in the Visual Basic 5 & 6 demos ...")
(No difference)

Revision as of 12:44, 23 January 2013

<A NAME="TeeChart_tutorial_5"></A>Tutorial 5 - Legend design



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.

Contents

<A HREF="#LegendControl">Legend control</a>

<A HREF="#Style">Style Tab</A>
<A HREF="#Position">Position Tab</A>
<A HREF="#Symbols">Symbols Tab</A>
<A HREF="#Title">Title Tab</A>
<A HREF="#Format">Format Tab</A>
<A HREF="#Border">Border Tab</A>
<A HREF="#Text">Text Tab</A>
<A HREF="#Gradient">Gradient Tab</A>
<A HREF="#Shadow">Shadow Tab</A>
<A HREF="#Emboss">Emboss Tab</A>
<A HREF="#Picture">Picture Tab</A>

<A HREF="#Customising">Customising Legends</a>

<A HREF="#OnGetLegendRect">OnGetLegendRect event</A>
<A HREF="#OnGetLegendPos">OnGetLegendPos event</A>
<A HREF="#OnGetLegendText">OnGetLegendText event</A>


<A NAME="LegendControl">Legend control</A>

Legend parameters are accessible via the Chart Editor, Chart tab, Legend page.

<img src="timages/legend.png">

   

Legend parameters. See Legend class help for more information

<A NAME="Style"></A>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 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 <A HREF="#Customising">Customising Legends</a>

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.

<A NAME="Position"></A>Position Tab

<img src="timages/legend2.png">

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 <A HREF="#Customising">customising</a> 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 <A HREF="#Customising">Customising Legends</a>.

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.

<A NAME="Symbols"></A>Symbols Tab

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.

<A NAME="Title"></A>Title Tab

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.

<A NAME="Format"></A>Format Tab

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.

<A NAME="Border"></A>Border Tab

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.

<A NAME="Text"></A>Text Tab

This page gives access to properties which change the appearance of the Legend text's font, outline, intercharacter spacing and shadow.

<A NAME="Gradient"></A>Gradient Tab

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

<A NAME="Shadow"></A>Shadow Tab

Sets the colour and size of the Legend's shadow.

<A NAME="Emboss"></A>Emboss Tab

You can add a personalised Embossing effect to the legend canvas by combining the colour, size, transparency and blur properties.

<A NAME="Picture"></A>Picture Tab

Adds an image to the Legend canvas which you can then modify in many ways using the different Filters, Style and position properties.


<A NAME="Customising">Customising Legends</a>

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

<A NAME="OnGetLegendRect"></A>OnGetLegendRect event

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

<A NAME="OnGetLegendPos"></A>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 Sub TChart1_OnGetLegendPos(ByVal Index As Long, X As Long, Y As Long, XColor As Long)
X = X - 100
End Sub

<A NAME="OnGetLegendText"></A>OnGetLegendText event

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.