1 /** 2 * Constructs a new mark anchor with default properties. 3 * 4 * @class Represents an anchor on a given mark. An anchor is itself a mark, but 5 * without a visual representation. It serves only to provide useful default 6 * properties that can be inherited by other marks. Each type of mark can define 7 * any number of named anchors for convenience. If the concrete mark type does 8 * not define an anchor implementation specifically, one will be inherited from 9 * the mark's parent class. 10 * 11 * <p>For example, the bar mark provides anchors for its four sides: left, 12 * right, top and bottom. Adding a label to the top anchor of a bar, 13 * 14 * <pre>bar.anchor("top").add(pv.Label);</pre> 15 * 16 * will render a text label on the top edge of the bar; the top anchor defines 17 * the appropriate position properties (top and left), as well as text-rendering 18 * properties for convenience (textAlign and textBaseline). 19 * 20 * @extends pv.Mark 21 */ 22 pv.Anchor = function() { 23 pv.Mark.call(this); 24 }; 25 26 pv.Anchor.prototype = pv.extend(pv.Mark) 27 .property("name"); 28 29 /** 30 * The anchor name. The set of supported anchor names is dependent on the 31 * concrete mark type; see the mark type for details. For example, bars support 32 * left, right, top and bottom anchors. 33 * 34 * <p>While anchor names are typically constants, the anchor name is a true 35 * property, which means you can specify a function to compute the anchor name 36 * dynamically. For instance, if you wanted to alternate top and bottom anchors, 37 * saying 38 * 39 * <pre>m.anchor(function() (this.index % 2) ? "top" : "bottom").add(pv.Dot);</pre> 40 * 41 * would have the desired effect. 42 * 43 * @type string 44 * @name pv.Anchor.prototype.name 45 */ 46