Skip to content

Commit 3ef30bd

Browse files
committed
Merge branch 'master' into gh-pages
2 parents fce247b + 27809e8 commit 3ef30bd

File tree

20 files changed

+268
-130
lines changed

20 files changed

+268
-130
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![npm dependencies](https://david-dm.org/vega/vega-lite.svg)](https://www.npmjs.com/package/vega-lite)
55
[![npm version](https://img.shields.io/npm/v/vega-lite.svg)](https://www.npmjs.com/package/vega-lite)
66

7-
**Vega-Lite is still in alpha phase and we are working on improving the code and [documentation](Documentation).
7+
**Vega-Lite is still in alpha phase and we are working on improving the code and [documentation](docs/Documentation.md).
88
Note that our syntax might change slightly before we release 1.0.**
99

1010
Vega-Lite provides a higher-level grammar for visual analysis, comparable to ggplot or Tableau, that generates complete [Vega](https://vega.github.io/) specifications.
@@ -14,7 +14,7 @@ Vega-Lite specifications consist of simple mappings of variables in a data set t
1414
If you are using Vega-Lite for your project(s), please let us know by emailing us at [Vega-Lite \[at\] cs.washington.edu](mailto:[email protected]). Feedback is also welcome.
1515
If you find a bug or have a feature request, please [create an issue](https://github.com/vega/vega-lite/issues/new).
1616

17-
Use Vega-Lite in the [online editor](https://vega.github.io/vega-lite/).
17+
__Try using Vega-lite in the online [Vega Editor](http://vega.github.io/vega-editor/?mode=vega-lite)__.
1818

1919
The complete schema for specifications as [JSON schema](http://json-schema.org/) is at [vega-lite-schema.json](https://vega.github.io/vega-lite/vega-lite-schema.json).
2020

@@ -29,9 +29,9 @@ We have more example visualizations in our [gallery](https://vega.github.io/vega
2929
"data": {"url": "data/barley.json"},
3030
"marktype": "point",
3131
"encoding": {
32-
"x": {"type": "Q","name": "yield","aggregate": "avg"},
32+
"x": {"type": "Q","name": "yield","aggregate": "mean"},
3333
"y": {
34-
"sort": [{"name": "yield","aggregate": "avg","reverse": false}],
34+
"sort": {"name": "yield","aggregate": "mean","reverse": false},
3535
"type": "O",
3636
"name": "variety"
3737
},

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "vega-lite",
33
"main": "vega-lite.js",
4-
"version": "0.8.1",
54
"homepage": "https://github.com/vega/vega-lite",
65
"authors": [
76
"Kanit Wongsuphasawat <[email protected]> (http://kanitw.yellowpigz.com)",

docs/Encoding-Mapping.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ Here are the list of common properties of the encoding property definition objec
1717

1818
| Property | Type | Description |
1919
| :------------ |:-------------:| :------------- |
20-
| name | String | A field/variable from which to pull a data value. __<sup>1</sup>__ |
21-
| value | String,Integer | |
20+
| name __<sup>1</sup>__ | String | A field/variable from which to pull a data value. |
21+
| value | String,Integer | A constant value |
2222
| type | String | Data Type (`Q` for quantitative, `O` for ordinal, `T` for temporal, and `N` for nominal). __<sup>2</sup>__ |
2323
| [axis](#axis) | Object | Configuration object for the encoding's axis |
2424
| [legends](#legends) | Object | Configuration object for the encoding's legends |
2525
| [scale](#scale) | Object | Configuration object for the encoding's scale |
26-
| [sort](#sort) | String \| Object | For all types of fields, if specified to `ascending` or `descending`, the domain values are sorted in based on the field's value in ascending or descending order. For nominal and ordinal fields, if set to an object, the values in the scale domain will be sorted based on an aggregate calculation over a specified sort field. <!-- TODO say what happen when sort is unspecified. --> See [Sort](#sort) section for more information. |
27-
| [aggregate](#aggregate) | String | Aggregation function for the field (`mean`, `sum`, `median`, `min`, `max`, `count`) |
28-
29-
| [bin](#bin) | Object | Binning properties. See [Binning](#Binning) |
26+
| [sort](#sort) | String \| Object | Sort order for a particular field. This can be string (`'ascending'`, `'descending'`, or `'unsorted'`) or a sort field definition object for sorting by an aggregate calculation of a specified sort field. If unspecified, the default value is `ascending`. See [Sort](#sort) section for more information. |
27+
| [aggregate](#aggregate) | String | Aggregation function for the field (e.g., `mean`, `sum`, `median`, `min`, `max`, `count`) |
28+
| [bin](#bin) | Boolean \| Object | Binning properties. See [Binning](#Binning) |
3029
| [timeUnit](#timeunit)| String | Property for converting time unit |
3130

3231

@@ -36,6 +35,14 @@ __<sup>1</sup>__ __Pending Revision__
3635
__<sup>2</sup>__ __Pending Revision__
3736
We are considering other properties of variables including specifying primitive type.
3837

38+
## field
39+
40+
__TODO__
41+
42+
43+
## type
44+
45+
__TODO__
3946

4047
## bin
4148

@@ -60,7 +67,7 @@ __Pending Revision__: Time Unit Conversion might be consolidated with "calculate
6067

6168
## aggregate
6269

63-
Vega-lite supports all [Vega aggregation operations](https://github.com/vega/vega/wiki/Data-Transforms#-aggregate).
70+
Vega-lite supports all [Vega aggregation operations](https://github.com/vega/vega/wiki/Data-Transforms#-aggregate) (e.g., `mean`, `sum`, `median`, `min`, `max`, `count`).
6471

6572
If at least one of the specified encoding channel contains aggregation, a summary data table (`aggregate`) will be computed from the source data table (after binning and time unit have been derived) and the resulting visualization shows data from this summary table. In this case, all fields without aggregation function specified are treated as dimensions. The summary statistics are grouped by these dimensions.
6673

@@ -116,9 +123,9 @@ Moreover, Vega-lite supports the following additional axis properties.
116123
| titleOffset | Integer | Offset between the axis title and the axis. |
117124

118125
<sup>1</sup>
119-
If `grid` is unspecified, the default value is `true` for ROW and COL. For X
120-
and Y, the default value is `true` for quantitative and time fields and `false`
121-
otherwise.
126+
If `grid` is unspecified, the default value is `true` for ROW and COL.
127+
For X and Y, the default value is `true` for (1) quantitative fields that are not binned and (2) time fields.
128+
Otherwise, the default value is `false`.
122129

123130
<sup>2</sup>
124131
If `title` is unspecified, the default value is produced from the field's name and transformation function applied e.g, "field_name", "SUM(field_name)", "BIN(field_name)", "YEAR(field_name)".
@@ -142,17 +149,20 @@ For now please see [legends json schema in schema.js](https://github.com/uwdata/
142149

143150
## sort
144151

145-
`sort` property can be specify for sorting the field's values in multiple ways:
152+
`sort` property can be specify for sorting the field's values in two ways:
153+
154+
1. (Supported by all types of fields) as __String__ with the following values:
155+
- `'ascending'` – the field is sort by the field's value in ascending order. This is the default value when `sort` is not specified.
156+
- `'descending'` – the field is sort by the field's value in descending order.
157+
- `'unsorted`' – The field is not sorted. (This is equivalent to specifying `sort:false` in [Vega's scales](https://github.com/vega/vega/wiki/Scales).)
146158

147-
- `undefined` - the field is unsorted.
148-
- (as __String__) `'ascending'` or `'descending'` – the field is sort by the field's value in ascending or descending order.
149-
- (as __Object__) A sort field object - for sorting the field by an aggregate calculation over a specified sort field. A sort field object has the following properties:
159+
2. (Supported by nominal and ordinal fields only) as a __sort field definition object__ - for sorting the field by an aggregate calculation over another sort field. A sort field object has the following properties:
150160

151161
| Property | Type | Description |
152162
| :------------ |:-------------:| :------------- |
153163
| _sort.field_ | Field | The field name to aggregate over.|
154164
| _sort.op_ | String | A valid [aggregation operation](Data-Transforms#-aggregate) (e.g., `mean`, `median`, etc.).|
155-
| _sort.order_ | String | (Optional) `'ascending'` or `'descending'` order. |
165+
| _sort.order_ | String | `'ascending'` or `'descending'` order. |
156166

157167

158168

gallery/examples.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// jshint quotmark: false
23

34
var EXAMPLES = [
45
{
@@ -252,6 +253,81 @@ var EXAMPLES = [
252253
},
253254
'data': {'url': 'data/cars.json'}
254255
}
256+
},{
257+
title: 'Histogram',
258+
spec: {
259+
"marktype": "bar",
260+
"encoding": {
261+
"x": {"bin": true,"name": "Acceleration","type": "Q"},
262+
"y": {
263+
"name": "*",
264+
"aggregate": "count",
265+
"type": "Q",
266+
"displayName": "Number of Records"
267+
}
268+
},
269+
"data": {"url": "data/cars.json"}
270+
}
271+
},{
272+
title: 'Horizontal Histogram',
273+
spec: {
274+
"marktype": "bar",
275+
"encoding": {
276+
"y": {"bin": true,"name": "Acceleration","type": "Q"},
277+
"x": {
278+
"name": "*",
279+
"aggregate": "count",
280+
"type": "Q",
281+
"displayName": "Number of Records"
282+
}
283+
},
284+
"data": {"url": "data/cars.json"}
285+
}
286+
},{
287+
title: 'Histogram with point instead',
288+
spec: {
289+
"marktype": "point",
290+
"encoding": {
291+
"x": {"bin": true,"name": "Acceleration","type": "Q"},
292+
"y": {
293+
"name": "*",
294+
"aggregate": "count",
295+
"type": "Q",
296+
"displayName": "Number of Records"
297+
}
298+
},
299+
"data": {"url": "data/cars.json"}
300+
}
301+
},{
302+
title: 'Histogram with line instead',
303+
spec: {
304+
"marktype": "line",
305+
"encoding": {
306+
"x": {"bin": true,"name": "Acceleration","type": "Q"},
307+
"y": {
308+
"name": "*",
309+
"aggregate": "count",
310+
"type": "Q",
311+
"displayName": "Number of Records"
312+
}
313+
},
314+
"data": {"url": "data/cars.json"}
315+
}
316+
},{
317+
title: 'Histogram with area instead',
318+
spec: {
319+
"marktype": "area",
320+
"encoding": {
321+
"x": {"bin": true,"name": "Acceleration","type": "Q"},
322+
"y": {
323+
"name": "*",
324+
"aggregate": "count",
325+
"type": "Q",
326+
"displayName": "Number of Records"
327+
}
328+
},
329+
"data": {"url": "data/cars.json"}
330+
}
255331
}
256332
];
257333

gulp/bumpver.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
var gulp = require('gulp');
44
var $ = require('gulp-load-plugins')();
55

6-
76
function inc(importance) {
8-
// get all the files to bump version in
9-
return gulp.src(['./package.json', './bower.json'])
10-
// bump the version number in those files
11-
.pipe($.bump({type: importance}))
12-
// save it back to filesystem
13-
.pipe(gulp.dest('./'));
7+
// get all the files to bump version in
8+
return gulp.src(['./package.json'])
9+
// bump the version number in those files
10+
.pipe($.bump({type: importance}))
11+
// save it back to filesystem
12+
.pipe(gulp.dest('./'));
1413
}
1514

1615
gulp.task('patch', function() { return inc('patch'); });

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vega-lite",
33
"author": "Jeffrey Heer, Dominik Moritz, Kanit \"Ham\" Wongsuphasawat",
4-
"version": "0.8.2",
4+
"version": "0.8.3",
55
"collaborators": [
66
"Kanit Wongsuphasawat <[email protected]> (http://kanitw.yellowpigz.com)",
77
"Dominik Moritz <[email protected]> (http://domoritz.de)",
@@ -34,45 +34,45 @@
3434
},
3535
"homepage": "https://github.com/vega/vega-lite",
3636
"devDependencies": {
37-
"browser-sync": "^2.8.2",
38-
"browserify": "^11.0.1",
37+
"browser-sync": "^2.9.11",
38+
"browserify": "^11.2.0",
3939
"browserify-shim": "^3.8.10",
4040
"browserify-versionify": "^1.0.6",
41-
"chai": "^3.2.0",
42-
"commander": "^2.8.1",
41+
"chai": "^3.4.0",
42+
"commander": "^2.9.0",
4343
"d3": "^3.5.6",
44-
"deep-diff": "^0.3.2",
44+
"deep-diff": "^0.3.3",
4545
"gulp": "^3.9.0",
46-
"gulp-bump": "^0.3.1",
47-
"gulp-git": "^1.3.1",
46+
"gulp-bump": "^1.0.0",
47+
"gulp-git": "^1.6.0",
4848
"gulp-jshint": "^1.11.2",
49-
"gulp-load-plugins": "^1.0.0-rc",
49+
"gulp-load-plugins": "^1.0.0",
5050
"gulp-rename": "^1.2.2",
51-
"gulp-run": "^1.6.10",
52-
"gulp-sourcemaps": "^1.5.2",
51+
"gulp-run": "^1.6.11",
52+
"gulp-sourcemaps": "^1.6.0",
5353
"gulp-spawn-mocha": "^2.2.1",
5454
"gulp-tag-version": "^1.3.0",
55-
"gulp-uglify": "^1.4.0",
56-
"gulp-util": "^3.0.6",
55+
"gulp-uglify": "^1.4.2",
56+
"gulp-util": "^3.0.7",
5757
"jshint-stylish": "^2.0.1",
5858
"lodash": "^3.10.1",
59-
"mocha": "^2.3.0",
59+
"mocha": "^2.3.3",
6060
"require-dir": "^0.3.0",
6161
"vinyl-buffer": "^1.0.0",
6262
"vinyl-source-stream": "^1.1.0",
6363
"watchify": "~3.4.0",
64-
"z-schema": "^3.12.4",
65-
"jstransform": "^11.0.2",
64+
"z-schema": "^3.15.4",
65+
"jstransform": "^11.0.3",
6666
"through": "^2.3.8"
6767
},
6868
"dependencies": {
6969
"colorbrewer": "0.0.2",
70-
"d3-color": "^0.2.4",
71-
"d3-format": "^0.3.0",
72-
"d3-time-format": "0.1.0",
73-
"datalib": "^1.4.5",
74-
"yargs": "^3.23.0",
75-
"vega": "^2.3.0"
70+
"d3-color": "^0.2.6",
71+
"d3-format": "^0.3.3",
72+
"d3-time-format": "0.1.3",
73+
"datalib": "^1.4.6",
74+
"yargs": "^3.29.0",
75+
"vega": "^2.3.1"
7676
},
7777
"browserify": {
7878
"transform": [

src/compiler/axis.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ axis.grid = function(def, encoding, name, layout) {
8181

8282
var _grid = encoding.axis(name).grid;
8383

84-
// If `grid` is unspecified, the default value is `true` for ROW and COL. For X
85-
// and Y, the default value is `true` for quantitative and time fields and `false` otherwise.
84+
// If `grid` is unspecified, the default value is `true` for ROW and COL.
85+
// For X and Y, the default value is `true` for (1) quantitative fields that are not binned and (2) time fields.
86+
// Otherwise, the default value is `false`.
8687
var grid = _grid === undefined ?
87-
(name === ROW || name === COL || encoding.isTypes(name, [Q, T])) :
88-
_grid;
88+
( name === ROW || name === COL ||
89+
(encoding.isTypes(name, [Q, T]) && !encoding.encDef(name).bin)
90+
) : _grid;
8991

9092
if (grid) {
9193
def.grid = true;

src/compiler/compiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ compiler.compileEncoding = function (encoding, stats) {
9191
var details = encoding.details();
9292

9393
if (details.length > 0 && lineType) {
94-
//subfacet to group stack / line together in one group
95-
compiler.subfacet(group, mdef, details, encoding);
94+
//subfacet to group area / line together in one group
95+
compiler.subfacet(group, mdef, details);
9696
}
9797

9898
// auto-sort line/area values

src/compiler/data.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,18 @@ data.raw.transform.bin = function(encoding) {
114114
transform.push({
115115
type: 'bin',
116116
field: encDef.name,
117-
output: {start: encoding.fieldRef(encType)},
117+
output: {
118+
start: encoding.fieldRef(encType, {bin_suffix: '_start'}),
119+
end: encoding.fieldRef(encType, {bin_suffix: '_end'})
120+
},
118121
maxbins: encoding.bin(encType).maxbins
119122
});
123+
// temporary fix for adding missing `bin_mid` from the bin transform
124+
transform.push({
125+
type: 'formula',
126+
field: encoding.fieldRef(encType, {bin_suffix: '_mid'}),
127+
expr: '(' + encoding.fieldRef(encType, {datum:1, bin_suffix: '_start'}) + '+' + encoding.fieldRef(encType, {datum:1, bin_suffix: '_end'}) + ')/2'
128+
});
120129
}
121130
return transform;
122131
}, []);
@@ -190,7 +199,15 @@ data.aggregate = function(encoding) {
190199
meas[encDef.name][encDef.aggregate] = true;
191200
}
192201
} else {
193-
dims[encDef.name] = encoding.fieldRef(encType);
202+
if (encDef.bin) {
203+
// TODO(#694) only add dimension for the required ones.
204+
dims[encoding.fieldRef(encType, {bin_suffix: '_start'})] = encoding.fieldRef(encType, {bin_suffix: '_start'});
205+
dims[encoding.fieldRef(encType, {bin_suffix: '_mid'})] = encoding.fieldRef(encType, {bin_suffix: '_mid'});
206+
dims[encoding.fieldRef(encType, {bin_suffix: '_end'})] = encoding.fieldRef(encType, {bin_suffix: '_end'});
207+
} else {
208+
dims[encDef.name] = encoding.fieldRef(encType);
209+
}
210+
194211
}
195212
});
196213

0 commit comments

Comments
 (0)