.netCHARTING v9.0 Documentation Send comments on this topic.
Formatting Values
See Also
Getting Started > General Tutorials > Using labels > Formatting Values

Glossary Item Box

Formatting Basics

Axes host the main format settings for themselves and related values on a chart. This means the the Y axis format string setting will affect the element's y value format in a string. The axis properties associated with formatting are Axis.FormatString and Axis.CultureName.

 

FormatString

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

For more information on using format strings see:

 

Tip: Another way to specify currency formatting within the labels text is to use: "$ <%Value,###,###.##>"

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.DefaultAxis.FormatString = "Currency";
[Visual Basic]
Chart.DefaultAxis.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.

See Also

©2018. All Rights Reserved.