code: function pivotKeys(key, limit, pulse) {
    var map = {},
        list = [];
  
    pulse.visit(pulse.SOURCE, function(t) {
      var k = key(t);
      if (!map[k]) {
        map[k] = 1;
        list.push(k);
      }
    });
  
    // TODO? Move this comparator to vega-util?
    list.sort(function(u, v) {
      return (u<v||u==null) && v!=null ? -1
        : (u>v||v==null) && u!=null ? 1
        : ((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))!==u && v===v ? -1
        : v!==v && u===u ? 1 : 0;
    });
  
    return limit ? list.slice(0, limit) : list;
  }
docs: Collect (and optionally limit) all unique pivot values.