text: vg.parse.legends = (function() {
  
    function legends(spec, legends, scales) {
      (spec || []).forEach(function(def, index) {
        legends[index] = legends[index] || vg.scene.legend();
        legend(def, index, legends[index], scales);
      });
    };
  
    function legend(def, index, legend, scales) {
      // legend scales
      legend.size  (def.size   ? scales[def.size]   : null);
      legend.shape (def.shape  ? scales[def.shape]  : null);
      legend.fill  (def.fill   ? scales[def.fill]   : null);
      legend.stroke(def.stroke ? scales[def.stroke] : null);
  
      // legend orientation
      if (def.orient) legend.orient(def.orient);
  
      // legend offset
      if (def.offset != null) legend.offset(def.offset);
  
      // legend title
      legend.title(def.title || null);
  
      // legend values
      legend.values(def.values || null);
  
      // legend label formatting
      legend.format(def.format !== undefined ? def.format : null);
  
      // style properties
      var p = def.properties;
      legend.titleProperties(p && p.title || {});
      legend.labelProperties(p && p.labels || {});
      legend.legendProperties(p && p.legend || {});
      legend.symbolProperties(p && p.symbols || {});
      legend.gradientProperties(p && p.gradient || {});
    }
    
    return legends;
  })();