protovis part 2: lines and labels

Labeling the tick lines

OK. So lets add some labels to the tick lines. Put your cursor after the strokeStyle but before the semicolon and hit return. Type add.(pv.Label) to use the label class.

You can see labels appear in the chart. We need to change the alignment and this can be a little confusing. The nomenclature is the opposite of what it would be in typesetting. Here, the type is aligned to the left property that we defined earlier in the chain.

Type .textAlign("right") and the text shifts so that the left property is to the right of the text. Then type .textBaseline("middle") to vertically align the text to the tick lines.

It's kind of confusing but you'll get used it. Protovis also lets you define simple font changes. Type .font("bold 6pt sans-serif"). Finally, type .textStyle("gray") to change the type color. Now the labels match the tick lines.