Repository: vega/vega-lite
Pull request #687 (2015-10-21 17:39:40)

Use new vega 2.3 bin transform
https://github.com/vega/vega/pull/388

Requires update to vega 2.3.

Also help remove `stats` from data (one TODO in #648)


Patch:
diff --git a/editor/bower.json b/editor/bower.json
index 9099cc395..1e3a8e1f6 100644
--- a/editor/bower.json
+++ b/editor/bower.json
@@ -15,7 +15,7 @@
     "tests"
   ],
   "dependencies": {
-    "vega": "^2.2.6",
+    "vega": "^2.3.0",
     "jquery": "~2.1.4",
     "z-schema": "~3.15.3"
   }
diff --git a/gallery/bower.json b/gallery/bower.json
index d9831c0e3..f025c71ba 100644
--- a/gallery/bower.json
+++ b/gallery/bower.json
@@ -15,7 +15,7 @@
     "tests"
   ],
   "dependencies": {
-    "vega": "^2.2.6",
+    "vega": "^2.3.0",
     "angular": "^1.4.3",
     "z-schema": "~3.15.3"
   }
diff --git a/package.json b/package.json
index 368df1d5a..acc52005c 100644
--- a/package.json
+++ b/package.json
@@ -72,7 +72,7 @@
     "d3-time-format": "0.1.0",
     "datalib": "^1.4.5",
     "yargs": "^3.23.0",
-    "vega": "2.2.6"
+    "vega": "^2.3.0"
   },
   "browserify": {
     "transform": [
diff --git a/src/compiler/compiler.js b/src/compiler/compiler.js
index d92ddc085..fb54992bd 100644
--- a/src/compiler/compiler.js
+++ b/src/compiler/compiler.js
@@ -53,8 +53,7 @@ compiler.compileEncoding = function (encoding, stats) {
       width: layout.width,
       height: layout.height,
       padding: 'auto',
-      // FIXME(#514): eliminate stats
-      data: compiler.data(encoding, stats),
+      data: compiler.data(encoding),
       // global scales contains only time unit scales
       scales: compiler.time.scales(encoding),
       marks: [{
@@ -130,4 +129,3 @@ compiler.compileEncoding = function (encoding, stats) {
 
   return spec;
 };
-
diff --git a/src/compiler/data.js b/src/compiler/data.js
index cf314d028..3ddd08166 100644
--- a/src/compiler/data.js
+++ b/src/compiler/data.js
@@ -17,9 +17,8 @@ var vlEncDef = require('../encdef'),
  *                 If the encoding contains aggregate value, this will also create
  *                 aggregate table as well.
  */
-// FIXME(#514): eliminate stats
-function data(encoding, stats) {
-  var def = [data.raw(encoding, stats)];
+function data(encoding) {
+  var def = [data.raw(encoding)];
 
   var aggregate = data.aggregate(encoding);
   if (aggregate) {
@@ -40,8 +39,7 @@ function data(encoding, stats) {
   return def;
 }
 
-// FIXME(#514): eliminate stats
-data.raw = function(encoding, stats) {
+data.raw = function(encoding) {
   var raw = {name: RAW};
 
   // Data source (url or inline)
@@ -59,7 +57,7 @@ data.raw = function(encoding, stats) {
     raw.format.parse = parse;
   }
 
-  raw.transform = data.raw.transform(encoding, stats);
+  raw.transform = data.raw.transform(encoding);
   return raw;
 };
 
@@ -84,14 +82,13 @@ data.raw.formatParse = function(encoding) {
  * Generate Vega transforms for the raw data table.  This can include
  * transforms for time unit, binning and filtering.
  */
-// FIXME(#514): eliminate stats
-data.raw.transform = function(encoding, stats) {
+data.raw.transform = function(encoding) {
   // null filter comes first so transforms are not performed on null values
   // time and bin should come before filter so we can filter by time and bin
   return data.raw.transform.nullFilter(encoding).concat(
     data.raw.transform.formula(encoding),
     data.raw.transform.time(encoding),
-    data.raw.transform.bin(encoding, stats),
+    data.raw.transform.bin(encoding),
     data.raw.transform.filter(encoding)
   );
 };
@@ -111,17 +108,14 @@ data.raw.transform.time = function(encoding) {
   }, []);
 };
 
-// FIXME(#514): eliminate stats
-data.raw.transform.bin = function(encoding, stats) {
+data.raw.transform.bin = function(encoding) {
   return encoding.reduce(function(transform, encDef, encType) {
     if (encoding.bin(encType)) {
       transform.push({
         type: 'bin',
         field: encDef.name,
-        output: {bin: encoding.fieldRef(encType)},
-        maxbins: encoding.bin(encType).maxbins,
-        min: stats[encDef.name].min,
-        max: stats[encDef.name].max
+        output: {start: encoding.fieldRef(encType)},
+        maxbins: encoding.bin(encType).maxbins
       });
     }
     return transform;


Test patch:
diff --git a/test/compiler/data.spec.js b/test/compiler/data.spec.js
index dfa268cd7..74cef1ebe 100644
--- a/test/compiler/data.spec.js
+++ b/test/compiler/data.spec.js
@@ -113,24 +113,15 @@ describe('data.raw', function() {
       }
     });
 
-    var stats = {
-      Acceleration: {
-        min: 0,
-        max: 100
-      }
-    };
-
     describe('bin', function() {
       it('should add bin transform', function() {
-        var transform = data.raw.transform.bin(encoding, stats);
+        var transform = data.raw.transform.bin(encoding);
 
         expect(transform[0]).to.eql({
           type: 'bin',
           field: 'Acceleration',
-          output: {bin: 'bin_Acceleration'},
-          maxbins: 15,
-          min: 0,
-          max: 100
+          output: {start: 'bin_Acceleration'},
+          maxbins: 15
         });
       });
     });
@@ -191,7 +182,7 @@ describe('data.raw', function() {
     });
 
     it('should have null filter, timeUnit, bin then filter', function () {
-      var transform = data.raw.transform(encoding, stats);
+      var transform = data.raw.transform(encoding);
       expect(transform[0].type).to.eql('filter');
       expect(transform[1].type).to.eql('formula');
       expect(transform[2].type).to.eql('bin');