Tour API Demos Download Tests
Aperture version 1.0
Generated by: JsDoc Toolkit 2.4.0

Class aperture.Format

Format objects are used by Scalars for formatting values for display, but may be used independently as well.

Class Summary
Constructor Attributes Constructor Name and Description
 
The default implementation of Format does nothing other than use the String() function to coerce the value to a String.

Method Summary

Class Detail

aperture.Format()
The default implementation of Format does nothing other than use the String() function to coerce the value to a String. Default formats for numbers and times are provided by the appropriate static method.

Method Detail

  • {String} format(value)
    Formats the specified value.
    Parameters:
    value
    The value to format.
    Returns:
    {String} The formatted value.
  • <static> {aperture.Format} aperture.Format.getNumberFormat(precision)
    Returns a number format object, suitable for formatting numeric values.
    Parameters:
    {Number} precision Optional
    The optional precision of the value to format. For numbers this will be a base number to round to, such as 1 or 0.001.
    Returns:
    {aperture.Format} a number format object.
  • <static> {aperture.Format} aperture.Format.getTimeFormat(precision)
    Returns a time format object, suitable for formatting dates and times.
    Parameters:
    {String} precision Optional
    The optional precision of the value to format. For times this will be a Date field reference, such as 'FullYear' or 'Seconds'.
    Returns:
    {aperture.Format} a time format object.
  • nextOrder()
    Given a level of precision in type specific form, returns the next (lesser) level of precision in type specific form, if and only if such orders of formatting are required for full expression of the value. This method is often used for a date axis and is best expressed by an example.

    When an axis is labeled to the precision of hours for instance, best practice would dictate that each hour not be labeled repeatedly by date, month and year, even those exist in the data. However if the axis spanned days, it would be desirable to label the beginning of each day, secondarily to each hour. This method provides the means of doing so:
    var hourFormat = aperture.Format.getTimeFormat( 'Hours' );
    
    // displays 'Date'
    alert( hourFormat.nextOrder() );
    Returns:
    The next precision level, or undefined if there isn't one.