Class pv.Anchor
Extends pv.Mark.
Represents an anchor on a given mark. An anchor is itself a mark, but without a visual representation. It serves only to provide useful default properties that can be inherited by other marks. Each type of mark can define any number of named anchors for convenience. If the concrete mark type does not define an anchor implementation specifically, one will be inherited from the mark's parent class.
For example, the bar mark provides anchors for its four sides: left, right, top and bottom. Adding a label to the top anchor of a bar,
bar.anchor("top").add(pv.Label);will render a text label on the top edge of the bar; the top anchor defines the appropriate position properties (top and left), as well as text-rendering properties for convenience (textAlign and textBaseline).
Defined in: Anchor.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Constructs a new mark anchor with default properties.
|
Field Attributes | Field Name and Description |
---|---|
The anchor name.
|
- Fields borrowed from class pv.Mark:
- bottom, childIndex, cursor, data, defaults, index, left, parent, proto, reverse, right, root, scene, title, top, type, visible
- Methods borrowed from class pv.Mark:
- add, anchor, anchorTarget, cousin, def, event, extend, first, last, mouse, render, sibling
The anchor name. The set of supported anchor names is dependent on the concrete mark type; see the mark type for details. For example, bars support left, right, top and bottom anchors.
While anchor names are typically constants, the anchor name is a true property, which means you can specify a function to compute the anchor name dynamically. For instance, if you wanted to alternate top and bottom anchors, saying
m.anchor(function() (this.index % 2) ? "top" : "bottom").add(pv.Dot);would have the desired effect.