Dundas Data Visualization Support Site
Dundas Support Site Home  |  Contact Us  |  Dundas Data Visualization  
Contact Us via Email

How do I format the labels, hyperlinks or tooltips of the chart?


Q. How do I format the labels, hyperlinks or tooltips of the chart?

A. The easiest way to set the format of the text in the chart is to use the Label Format dialog. This dialog provides various formats you can specify for the axis labels, as well as a place to specify custom formats along with tips. If you want to specify the format at run time, you can copy the desired format created using this dialog, and set the property in the code.

Formatting is provided using Microsoft Format Strings, which you can find out more about in the MSDN Library, if you choose. (Note that format strings differ in Dundas Chart from .NET in that the "P" and "%" characters do not multiply your data. This is intended to keep the original values intact and strictly format the text.)

To access this dialog, go to the Properties window for the chart control, then:

  • For axis labels, open the ChartAreas collection, open the Axes collection, select the axis, expand LabelStyle, and select the Format property. Click the ellipsis ("...") button.

  • For series or data points, open the Series collection. If you have enabled the ShowLabelAsValue property, select the LabelFormat property and click the ellipsis ("...") button.

    If you are setting the Label, Href, ToolTip or MapAreaAttributes properties to a custom string of text using keywords, select the property and click the button to open the keywords editor. When adding a keyword, you are given the option to format the value. Formatting is automatically added to keywords within curly braces, for example: "#MAX{C0}", where "C0" is the format string.

Here is a chart with no formatting on its axis labels:

In the following example, we are assigning a custom format string to the format the Y-axis labels, which can be done either in the designer or with code.

Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "$0,,M";

Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "$0,,M"

Here are a few examples of the kinds of formats you can provide:

  • "$3 million" - "$0,, million"
  • "$500 K" - "$0, K"
  • "$1,000,000.00" - "C"
  • "$1,000,000" - "C0"
  • "Oct 12, 2006" - "MMM dd, yyy"
  • "October 12, 2006 12:00 AM" - "f"