.netCHARTING v6.0 Documentation Send comments on this topic.
Formatting Advanced
Getting Started > General Tutorials > Using labels > Formatting Values > Formatting Advanced

Glossary Item Box

Advanced Formatting

DataEngine
When the data engine generates elements to be used in conjunction with category x axes* the element x values, despite being numeric or time based, are placed in the element.Name property as strings. To specify a format used in this process DataEngine.FormatString and DataEngine.CultureName are used.

* As opposed to a true numeric or time axis scales, category axes show elements by their name. 

Note: To bypass using element names and use the actual x values you can specify "XValue=__" in the dataEngine's DataFields property instead of "XAxis=___";


Embedded in Tokens

This section demonstrates how to use different formatting in labels so they dont use the axis format.

All values shown in a chart are based on a label template string which uses tokens that specify which element value to show. For example a regular combo chart shows y values for each element and this can be specified using the following code:

Elements show values when Chart.DefaultSeries.DefaultElement.ShowValue = true
[C#]

Chart.DefaultSeries.DefaultElement.SmartLabel.Text = "%YValue";
[Visual Basic]

Chart.DefaultSeries.DefaultElement.SmartLabel.Text = "%YValue"

To imbed format strings within the element's label template, the following syntax is used:
<Token,Format>

Example element templates:

Template Text Result
<%YValue,Currency> $500.00
(<%YValue,Currency>, <%XValue,d>) ($500.00, 11/18/2004) 

Example: The following code will specify a currency format for the default element label template.

[C#]
Chart.DefaultSeries.DefaultElement.SmartLabel.Text = "<%YValue,Currency>";
[Visual Basic]
Chart.DefaultSeries.DefaultElement.SmartLabel.Text = "<%YValue,Currency>"

This will format the labels on the chartArea as currency but not in other places like the legend box.

For a complete list of possible tokens see: Tokens

For a reference of how to access different label on a chart see Using Labels


Advanced Axis Formatting

The axis also provides some additional settings that influence the axis format.

Percent
Setting Axis.Percent = true will format axis tick labels as percentages (in addition to snapping the scales maximum value to 100%)

Decimal Places

A shortcut for setting the number of decimals for axis formats is to specify it with the Axis.NumberPrecision property.

Format strings that specify decimal spaces override this setting.
[C#]

Chart.YAxis.NumberPrecision = 2;
[Visual Basic]

Chart.YAxis.NumberPrecision = 2
©2010. All Rights Reserved.