Sha256: 96faa0a2c4690be7d99d3748a952de73f9ea8e57d296fc44a2129d842736a550

Contents?: true

Size: 1.45 KB

Versions: 23

Compression:

Stored size: 1.45 KB

Contents

pv.SvgScene.label = function(scenes) {
  var e = scenes.$g.firstChild;
  for (var i = 0; i < scenes.length; i++) {
    var s = scenes[i];

    /* visible */
    if (!s.visible) continue;
    var fill = s.textStyle;
    if (!fill.opacity || !s.text) continue;

    /* text-baseline, text-align */
    var x = 0, y = 0, dy = 0, anchor = "start";
    switch (s.textBaseline) {
      case "middle": dy = ".35em"; break;
      case "top": dy = ".71em"; y = s.textMargin; break;
      case "bottom": y = "-" + s.textMargin; break;
    }
    switch (s.textAlign) {
      case "right": anchor = "end"; x = "-" + s.textMargin; break;
      case "center": anchor = "middle"; break;
      case "left": x = s.textMargin; break;
    }

    e = this.expect(e, "text", {
        "pointer-events": s.events,
        "cursor": s.cursor,
        "x": x,
        "y": y,
        "dy": dy,
        "transform": "translate(" + s.left + "," + s.top + ")"
            + (s.textAngle ? " rotate(" + 180 * s.textAngle / Math.PI + ")" : "")
            + (this.scale != 1 ? " scale(" + 1 / this.scale + ")" : ""),
        "fill": fill.color,
        "fill-opacity": fill.opacity || null,
        "text-anchor": anchor
      }, {
        "font": s.font,
        "text-shadow": s.textShadow,
        "text-decoration": s.textDecoration
      });
    if (e.firstChild) e.firstChild.nodeValue = s.text;
    else e.appendChild(document.createTextNode(s.text));
    e = this.append(e, scenes, i);
  }
  return e;
};

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rubyvis-0.6.0 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.5.2 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.5.1 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.5.0 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.4.1 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.4.0 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.6 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.5 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.4 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.3 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.2 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.1 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.3.0 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.2.2 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.2.1 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.2.0 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.1.7 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.1.6 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.1.5 vendor/protovis/src/scene/SvgLabel.js
rubyvis-0.1.4 vendor/protovis/src/scene/SvgLabel.js