Overview
You can add any number of Titles objects to your chart by simply including those titles into the Titles collection, which is found in the root Chart object. The Title object incorporates several properties that can be used to position, dock, and control the appearance of any Title. Title positioning can be explicitly set, or you can specify that your title be docked. The charting control gives you full control over all of the appearance properties of your Titles, so you have the ability to set specific attributes for such things as fonts, or colors, and even text effects. All stylistic properties of the chart control can be accessed using the Style property.
Multi-Line Titles
You are not restricted to fitting your title's text onto one line, since any title may span multiple lines. If you want to insert a line break into your title text, and have your title continue onto a new line, then simply insert the \n new line character to signify that a new line has begun. Once inserted, this new line character allows your title to span onto the next line, as shown in Figure 1 below.
Figure 1: Multi-line chart title.
Adding Removing and Editing
You can add Titles to your charts programmatically, or you can use the Dundas Chart & Data Wizard™ to add a them. You can work with your Title objects from within the Property Browser of Visual Studio, and when you select a title collection from the Property Browser, the Titles Collection Editor will appear. This editor allows you set many of the properties of your titles. Simply select the specific title that you want to alter, from the title list in the left hand window, then set that title's properties in the right hand section of the editor. When you are done, you can dismiss the Titles Collection Editor using the OK button, and all of your alterations shall be applied to your titles accordingly. Figure 2 below shows the Title Collection Editor.
Figure 2: The Title Collection Editor.
Example
This example demonstrates how to create, modify, and remove the chart title text.
Visual Basic | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
Appearance
Each Title object may have its appearance modified by a set of properties. For instance, you can set the fore ground, or back ground colors of title text, you can also apply a gradient fill, or a hatching style to the Title region. The Title region also supports the use of borders, or shadowing. If you want to add a text effect to chart title, simply use of the Style property.
The effects, or styles, available to you include:
- Shadow.
- Emboss.
- Embed.
- Frame.
Figure 3 below illustrates some of the interesting effects that you add to your chart title text.
Figure 3: Using the style property, you can create many interesting titles. |
Docking and Alignment
A Title object may be docked to a ChartArea, or the Chart image. When docking to the ChartArea , the Title may be positioned inside or outside the ChartArea using the DockInsideChartArea boolean property. The possible choices for docking a chart title include Top, Bottom, Left, and Right. When the Left, or Right docking styles are used, the title text is automatically rotated.
In some cases, the default docking mechanism may not suit your needs exactly. For this reason, there is an additional property, called DockOffset, that you can use to position your chart titles more specifically. This property uses a positive, or negative integer value to represent the number of pixels to shift the Title region position. In addition to this, the Title object also contains an Alignment property that defines where in the Title region the text should be drawn. Some of the possible values for this property include: TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, or BottomRight.
Note |
---|
If a Title has been configured with explicit Position values, the Docking and Alignment properties will be ignored. |
Figure 4: Titles may be positioned.
Positioning
The Title object contains a Position object. By default, the Position.Auto property is set to set to True so that all positioning happens automatically. When the Position.Auto property is set to False, the Docking, Alignment, DockInsideChartArea, and DockOffset properties are ignored. Instead, the Position object's Height, Width, X, and Y properties are used to position the Title object.
Figure 5: Titles may be custom positioned.
Hrefs and Tooltips
Each Title object can have a Tooltip or Href assigned to it. A tooltip will allow for more information to be displayed with the title when the user hovers the mouse pointer over the Title object. The Href will allow a "hot" region for mouse selection to provide drilldown functionality into another web-page.