Glossary Item Box

Tutorials: Formatting Advanced

See Also .netCHARTING v3.1 Documentation Send comments on this topic.

Formatting Values

Formatting Basics

Axes host the main format settings for themselves and values on a chart. The axis properties that associated with formatting are Axis.FormatString and Axis.CultureName.

 

FormatString

The FormatString property uses the .net string format specifications to parse values.

For more info see:

 

Additional shortcuts and custom format strings are also available:

Shortcuts
• 'Currency' 
   Formats numeric values based on the currency of the machines current or specified culture.
• 'N:x'
   Shorthand format where 'x' specifies the number of decimal places for numeric values. i.e: 'N:2'

Custom Format Strings
 'Q'
  
With dates, 'q' will represent the quarter. For example: "Quarter: <%Value,q>"

 'O' (Numeric Values)
   An ordinal number. Adds a suffix to numbers for example: 1st 2nd 3rd etc.

 'O' (DateTime Values)
  
Day as an ordinal number. 1st 2nd 3rd etc.

 

[C#]

Chart.DefaultDefaultAxis.FormatString = "Currency";
[Visual Basic]
Chart.DefaultDefaultAxis.FormatString = "Currency"

Sample Settings:
{n:0}
Result:  140 (Number)

d
Result:  1/2/2005 (Date)

CultureName

The CultureName property accepts names from this list . It is used to automatically determine the type of formatting used for numbers or dates by the specified culture and format values accordingly.

[C#]

Chart.DefaultDefaultAxis.CultureName = "en-US";
[Visual Basic]

Chart.DefaultDefaultAxis.CultureName = "en-US"
Note: By default, the server's culture setting is used.

 

Element Value Formats

Element values on a chart are formatted based on the format settings of the axis related to the value used. This means that an element's YValue format will be based on the y axis and XValue based on the x axis format.

Assuming we have a chart where the x axis is time and y axis is numeric, the following code would properly format the element values.

[C#]

Chart.XAxis.FormatString = "d"; // A date format
Chart.YAxis.FormatString = "{n:0}"; // A numeric format
[Visual Basic]

Chart.XAxis.FormatString = "d" ' A date format
Chart.YAxis.FormatString = "{n:0}" ' A numeric format

Whenever an element or series value is used with multiple x or y axes, the format will be determined by the parent series axis.

Tips

  • Format settings are generally not required; .netCHARTING can automatically determine a suitable format for your data.

Tutorials: Formatting Advanced


2002 - 2005 Webavail Productions Inc. & Corporate Web Solutions Ltd.. All Rights Reserved.