1 /**
  2  * The top-level Protovis namespace. All public methods and fields should be
  3  * registered on this object. Note that core Protovis source is surrounded by an
  4  * anonymous function, so any other declared globals will not be visible outside
  5  * of core methods. This also allows multiple versions of Protovis to coexist,
  6  * since each version will see their own <tt>pv</tt> namespace.
  7  *
  8  * @namespace The top-level Protovis namespace, <tt>pv</tt>.
  9  */
 10 var pv = {};
 11 
 12 /**
 13  * Protovis major and minor version numbers.
 14  *
 15  * @namespace Protovis major and minor version numbers.
 16  */
 17 pv.version = {
 18   /**
 19    * The major version number.
 20    *
 21    * @type number
 22    * @constant
 23    */
 24   major: 3,
 25 
 26   /**
 27    * The minor version number.
 28    *
 29    * @type number
 30    * @constant
 31    */
 32   minor: 2
 33 };
 34 
 35 /**
 36  * Returns the passed-in argument, <tt>x</tt>; the identity function. This method
 37  * is provided for convenience since it is used as the default behavior for a
 38  * number of property functions.
 39  *
 40  * @param x a value.
 41  * @returns the value <tt>x</tt>.
 42  */
 43 pv.identity = function(x) { return x; };
 44 
 45 /**
 46  * Returns <tt>this.index</tt>. This method is provided for convenience for use
 47  * with scales. For example, to color bars by their index, say:
 48  *
 49  * <pre>.fillStyle(pv.Colors.category10().by(pv.index))</pre>
 50  *
 51  * This method is equivalent to <tt>function() this.index</tt>, but more
 52  * succinct. Note that the <tt>index</tt> property is also supported for
 53  * accessor functions with {@link pv.max}, {@link pv.min} and other array
 54  * utility methods.
 55  *
 56  * @see pv.Scale
 57  * @see pv.Mark#index
 58  */
 59 pv.index = function() { return this.index; };
 60 
 61 /**
 62  * Returns <tt>this.childIndex</tt>. This method is provided for convenience for
 63  * use with scales. For example, to color bars by their child index, say:
 64  *
 65  * <pre>.fillStyle(pv.Colors.category10().by(pv.child))</pre>
 66  *
 67  * This method is equivalent to <tt>function() this.childIndex</tt>, but more
 68  * succinct.
 69  *
 70  * @see pv.Scale
 71  * @see pv.Mark#childIndex
 72  */
 73 pv.child = function() { return this.childIndex; };
 74 
 75 /**
 76  * Returns <tt>this.parent.index</tt>. This method is provided for convenience
 77  * for use with scales. This method is provided for convenience for use with
 78  * scales. For example, to color bars by their parent index, say:
 79  *
 80  * <pre>.fillStyle(pv.Colors.category10().by(pv.parent))</pre>
 81  *
 82  * Tthis method is equivalent to <tt>function() this.parent.index</tt>, but more
 83  * succinct.
 84  *
 85  * @see pv.Scale
 86  * @see pv.Mark#index
 87  */
 88 pv.parent = function() { return this.parent.index; };
 89 
 90 /**
 91  * Stores the current event. This field is only set within event handlers.
 92  *
 93  * @type Event
 94  * @name pv.event
 95  */
 96