Class Index | File Index

Classes


Class pv.Label


Extends pv.Mark.
Represents a text label, allowing textual annotation of other marks or arbitrary text within the visualization. The character data must be plain text (unicode), though the text can be styled using the #font property. If rich text is needed, external HTML elements can be overlaid on the canvas by hand.

Labels are positioned using the box model, similarly to Dot. Thus, a label has no width or height, but merely a text anchor location. The text is positioned relative to this anchor location based on the #textAlign, #textBaseline and #textMargin properties. Furthermore, the text may be rotated using #textAngle.

Labels ignore events, so as to not interfere with event handlers on underlying marks, such as bars. In the future, we may support event handlers on labels.

See also the Label guide.
Defined in: Label.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new label mark with default properties.
Field Summary
Field Attributes Field Name and Description
 
Default properties for labels.
 
The font format, per the CSS Level 2 specification.
 
The character data to render; a string.
 
The horizontal text alignment.
 
The rotation angle, in radians.
 
The vertical text alignment.
 
A list of decoration to be applied to text, per the CSS Text Level 3 text-decoration property.
 
The text margin; may be specified in pixels, or in font-dependent units (such as ".1ex").
 
A list of shadow effects to be applied to text, per the CSS Text Level 3 text-shadow property.
 
The text color.
Fields borrowed from class pv.Mark:
bottom, childIndex, cursor, data, events, index, left, parent, proto, reverse, right, root, scale, title, top, type, visible
Methods borrowed from class pv.Mark:
add, anchor, anchorTarget, def, event, extend, margin, mouse, render
Class Detail
pv.Label()
Constructs a new label mark with default properties. Labels are not typically constructed directly, but by adding to a panel or an existing mark via pv.Mark#add.
Field Detail
{pv.Label} defaults
Default properties for labels. See the individual properties for the default values.

{string} font
The font format, per the CSS Level 2 specification. The default font is "10px sans-serif", for consistency with the HTML 5 canvas element specification. Note that since text is not wrapped, any line-height property will be ignored. The other font-style, font-variant, font-weight, font-size and font-family properties are supported.
See:
CSS2 fonts

{string} text
The character data to render; a string. The default value of the text property is the identity function, meaning the label's associated datum will be rendered using its toString.

{string} textAlign
The horizontal text alignment. One of:The default horizontal alignment is left.

{number} textAngle
The rotation angle, in radians. Text is rotated clockwise relative to the anchor location. For example, with the default left alignment, an angle of Math.PI / 2 causes text to proceed downwards. The default angle is zero.

{string} textBaseline
The vertical text alignment. One of:The default vertical alignment is bottom.

{string} textDecoration
A list of decoration to be applied to text, per the CSS Text Level 3 text-decoration property. An example specification is "underline".
See:
CSS3 text

{number} textMargin
The text margin; may be specified in pixels, or in font-dependent units (such as ".1ex"). The margin can be used to pad text away from its anchor location, in a direction dependent on the horizontal and vertical alignment properties. For example, if the text is left- and middle-aligned, the margin shifts the text to the right. The default margin is 3 pixels.

{string} textShadow
A list of shadow effects to be applied to text, per the CSS Text Level 3 text-shadow property. An example specification is "0.1em 0.1em 0.1em rgba(0,0,0,.5)"; the first length is the horizontal offset, the second the vertical offset, and the third the blur radius.
See:
CSS3 text

{string} textStyle
The text color. The name "textStyle" is used for consistency with "fillStyle" and "strokeStyle", although it might be better to rename this property (and perhaps use the same name as "strokeStyle"). The default color is black.
See:
pv.color

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