Posted by: Cirilo Meggiolaro | 01/8/2009

Tip of the day #86 – Exploring the Microsoft Chart control – Titles

The Microsoft Chart control has a property called Titles that allows you to create as many titles to your chart as you need. A title may be used to the whole chart, to a specific chart area or with custom position. There are enough settings that you may change as font color, size, orientation, size, location, background image, borders and so on.

You may create a title using the Title Collection Editor as demonstrated in the picture 1 or creating your own instance of the Title class and adding it to the chart control Titles collection:

Picture 1 - The Titles Collection Editor dialog.

Picture 1 - The Titles Collection Editor dialog.

Constructor overloads

public Title();
public Title(string text);
public Title(string text, Docking docking);
public Title(string text, Docking docking, Font font, Color color);

Properties

  • ContentAlignment Alignment: Gets or sets the alignment of the title;
  • Color BackColor: Gets or sets the background color of the title;
  • GradientStyle BackGradientStyle: Gets or sets the orientation for the background gradient of a title. If set to none, a gradient is not used;
  • ChartHatchStyle BackHatchStyle: Gets or sets the hatching style for the title;
  • string BackImage: Gets or sets the background image of the title;
  • ChartImageAlignmentStyle BackImageAlignment: Gets or sets the alignment of the title background image;
  • Color BackImageTransparentColor: Gets or sets a color that will be drawn as transparent when the background image is drawn;
  • ChartImageWrapMode BackImageWrapMode: Gets or sets the drawing mode for the background image of the title;
  • Color BackSecondaryColor: Gets or sets the secondary color of the title background;
  • Color BorderColor: Gets or sets the border color of the title;
  • ChartDashStyle BorderDashStyle: Gets or sets the border style of the title;
  • int BorderWidth: Gets or sets the border width of the title;
  • string DockedToChartArea: Gets or sets the name of the chart area where the title will be docked. If no chart are is defined, the title is docked to the whole chart control;
  • Docking Docking: Gets or sets a value that determines where the title is docked;
  • int DockingOffset: Gets or sets the offset of the docked title position;
  • Font Font: Gets or sets the text font;
  • Color ForeColor: Gets or sets the text color;
  • bool IsDockedInsideChartArea: Gets or sets a flag that specifies whether the title should be docked within a chart area;
  • ElementPosition Position: Gets or sets the custom position for the title;
  • Color ShadowColor: Gets or sets the shadow color for the title;
  • int ShadowOffset: Gets or sets the shadow offset of the title (pixels);
  • string Text: Gets or sets the title text;
  • TextOrientation TextOrientation: Gets or sets the orientation of the text such as horizontal, rotated and so on;
  • TextStyle TextStyle: Gets or sets the text style such as shadow, emboss, embed and so on;
  • string ToolTip: Gets or sets the tooltip for the title;
  • bool Visible: Gets or sets a flag that specifies whether the title is visible or not.

The following picture shows three titles added to the chart:

  • A top title aligned to the right, not docked to the chart area;
  • The blue title has been aligned to the center and docked to the chart area;
  • A rotated title with custom position and size.
Picture 2 - Three titles added to the chart.

Picture 2 - Three titles added to the chart.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: