1 pv.SvgScene.label = function(scenes) {
  2   var e = scenes.$g.firstChild;
  3   for (var i = 0; i < scenes.length; i++) {
  4     var s = scenes[i];
  5 
  6     /* visible */
  7     if (!s.visible) continue;
  8     var fill = s.textStyle;
  9     if (!fill.opacity || !s.text) continue;
 10 
 11     /* text-baseline, text-align */
 12     var x = 0, y = 0, dy = 0, anchor = "start";
 13     switch (s.textBaseline) {
 14       case "middle": dy = ".35em"; break;
 15       case "top": dy = ".71em"; y = s.textMargin; break;
 16       case "bottom": y = "-" + s.textMargin; break;
 17     }
 18     switch (s.textAlign) {
 19       case "right": anchor = "end"; x = "-" + s.textMargin; break;
 20       case "center": anchor = "middle"; break;
 21       case "left": x = s.textMargin; break;
 22     }
 23 
 24     e = this.expect(e, "text", {
 25         "pointer-events": s.events,
 26         "cursor": s.cursor,
 27         "x": x,
 28         "y": y,
 29         "dy": dy,
 30         "transform": "translate(" + s.left + "," + s.top + ")"
 31             + (s.textAngle ? " rotate(" + 180 * s.textAngle / Math.PI + ")" : "")
 32             + (this.scale != 1 ? " scale(" + 1 / this.scale + ")" : ""),
 33         "fill": fill.color,
 34         "fill-opacity": fill.opacity || null,
 35         "text-anchor": anchor
 36       }, {
 37         "font": s.font,
 38         "text-shadow": s.textShadow,
 39         "text-decoration": s.textDecoration
 40       });
 41     if (e.firstChild) e.firstChild.nodeValue = s.text;
 42     else e.appendChild(document.createTextNode(s.text));
 43     e = this.append(e, scenes, i);
 44   }
 45   return e;
 46 };
 47