Class Index | File Index

Classes


Class pv.Format

Represents an abstract text formatter and parser. A format is a function that converts an object of a given type, such as a Date, to a human-readable string representation. The format may also have a #parse method for converting a string representation back to the given object type.

Because formats are themselves functions, they can be used directly as mark properties. For example, if the data associated with a label are dates, a date format can be used as label text:

    .text(pv.Format.date("%m/%d/%y"))
And as with scales, if the format is used in multiple places, it can be convenient to declare it as a global variable and then reference it from the appropriate property functions. For example, if the data has a date attribute, and format references a given date format:
    .text(function(d) format(d.date))
Similarly, to parse a string into a date:
var date = format.parse("4/30/2010");
Not all format implementations support parsing. See the implementing class for details.
Defined in: Format.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Abstract; see an implementing class.
Method Summary
Method Attributes Method Name and Description
 
format(x)
Formats the specified object, returning the string representation.
 
parse(x)
Parses the specified string, returning the object representation.
Class Detail
pv.Format()
Abstract; see an implementing class.
See:
pv.Format.date
pv.Format.number
pv.Format.time
Method Detail
{string} format(x)
Formats the specified object, returning the string representation.
Parameters:
{object} x
the object to format.
Returns:
{string} the formatted string.

{object} parse(x)
Parses the specified string, returning the object representation.
Parameters:
{string} x
the string to parse.
Returns:
{object} the parsed object.

Documentation generated by JsDoc Toolkit 2.3.2 on Sun May 30 2010 18:10:24 GMT-0700 (PDT)