Socket
Socket
Sign inDemoInstall

vega-lite

Package Overview
Dependencies
Maintainers
2
Versions
469
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-lite - npm Package Compare versions

Comparing version 0.6.12 to 0.7.0

2

bower.json
{
"name": "vega-lite",
"main": "vega-lite.js",
"version": "0.6.9",
"version": "0.7.0",
"homepage": "https://github.com/uwdata/vega-lite",

@@ -6,0 +6,0 @@ "authors": [

@@ -78,3 +78,3 @@ 'use strict';

vled.parse = function() {
var spec, encoding, source;
var spec, encoding;
try {

@@ -205,3 +205,3 @@ spec = JSON.parse(d3.select("#vlspec").property("value"));

marktype: "point",
enc: {
encoding: {
x: {type: "Q",name: "yield",aggr: "avg"},

@@ -208,0 +208,0 @@ y: {

{
"name": "vega-lite",
"author": "Jeffrey Heer, Dominik Moritz, Kanit \"Ham\" Wongsuphasawat",
"version": "0.6.12",
"version": "0.7.0",
"collaborators": [

@@ -6,0 +6,0 @@ "Kanit Wongsuphasawat <kanitw@gmail.com> (http://kanitw.yellowpigz.com)",

@@ -1,2 +0,2 @@

# Vega-lite [![Build Status](https://travis-ci.org/uwdata/vega-lite.svg)](https://travis-ci.org/uwdata/vega-lite)
# Vega-lite [![Build Status](https://travis-ci.org/uwdata/vega-lite.svg)](https://travis-ci.org/uwdata/vega-lite) [![npm dependencies](https://david-dm.org/uwdata/vega-lite.svg)](https://www.npmjs.com/package/vega-lite) [![npm version](https://img.shields.io/npm/v/vega-lite.svg)](https://www.npmjs.com/package/vega-lite)

@@ -9,4 +9,9 @@ **Vega-lite is work in progress and we are working on improving the code and documentation.**

The complete schema for specifications as [JSON schema](http://json-schema.org/) is at [spec.json](https://uwdata.github.io/vega-lite/spec.json). Use Vega-lite in the [online editor](https://uwdata.github.io/vega-lite/).
Use Vega-lite in the [online editor](https://uwdata.github.io/vega-lite/).
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:vega-lite@cs.washington.edu). Feedbacks are also welcomed.
If you find a bug or have a feature request, please [create an issue](https://github.com/uwdata/vega-lite/issues/new).
The complete schema for specifications as [JSON schema](http://json-schema.org/) is at [spec.json](https://uwdata.github.io/vega-lite/spec.json).
## Example specification

@@ -13,0 +18,0 @@

@@ -16,8 +16,8 @@ 'use strict';

encoding.forEach(function(field, encType) {
if (field.aggr) {
if (field.aggr === 'count') {
if (field.aggregate) {
if (field.aggregate === 'count') {
meas.count = {op: 'count', field: '*'};
}else {
meas[field.aggr + '|'+ field.name] = {
op: field.aggr,
meas[field.aggregate + '|'+ field.name] = {
op: field.aggregate,
field: 'data.'+ field.name

@@ -24,0 +24,0 @@ };

@@ -44,3 +44,3 @@ 'use strict';

def.grid = true;
def.layer = (isRow || isCol) ? 'front' : 'back';
def.layer = 'back';

@@ -47,0 +47,0 @@ if (isCol) {

@@ -104,3 +104,3 @@ 'use strict';

maxLength = getMaxLength(encoding, stats, x);
} else if (encoding.aggr(x) === 'count') {
} else if (encoding.aggregate(x) === 'count') {
//assign default value for count as it won't have stats

@@ -107,0 +107,0 @@ maxLength = 3;

@@ -19,3 +19,3 @@ 'use strict';

return {
op: d.aggr,
op: d.aggregate,
field: 'data.' + d.name

@@ -27,3 +27,3 @@ };

var reverse = (d.reverse ? '-' : '');
return reverse + 'data.' + (d.aggr==='count' ? 'count' : (d.aggr + '_' + d.name));
return reverse + 'data.' + (d.aggregate==='count' ? 'count' : (d.aggregate + '_' + d.name));
});

@@ -30,0 +30,0 @@

@@ -38,3 +38,3 @@ "use strict";

groupby: [encoding.field(dim)].concat(facets), // dim and other facets
fields: [{op: 'sum', field: encoding.field(val)}] // TODO check if field with aggr is correct?
fields: [{op: 'sum', field: encoding.field(val)}] // TODO check if field with aggregate is correct?
}]

@@ -41,0 +41,0 @@ };

'use strict';
require('./globals');
var vldata = module.exports = {};

@@ -7,8 +9,8 @@

vldata.types = {
'boolean': 'O',
'number': 'Q',
'integer': 'Q',
'date': 'T',
'string': 'O'
'boolean': O,
'number': Q,
'integer': Q,
'date': T,
'string': O
};

@@ -30,3 +30,3 @@ // utility for enc

for (var k in enc) {
if (vlenc.has(enc, k) && enc[k].aggr) {
if (vlenc.has(enc, k) && enc[k].aggregate) {
return true;

@@ -33,0 +33,0 @@ }

@@ -12,18 +12,9 @@ 'use strict';

module.exports = (function() {
function Encoding(marktype, enc, data, config, filter, theme) {
var defaults = schema.instantiate();
function Encoding(spec, theme) {
var defaults = schema.instantiate(),
specExtended = schema.util.merge(defaults, theme || {}, spec) ;
var spec = {
data: data,
marktype: marktype,
enc: enc,
config: config,
filter: filter || []
};
var specExtended = schema.util.merge(defaults, theme || {}, spec) ;
this._data = specExtended.data;
this._marktype = specExtended.marktype;
this._enc = specExtended.enc;
this._enc = specExtended.encoding;
this._config = specExtended.config;

@@ -35,2 +26,61 @@ this._filter = specExtended.filter;

Encoding.fromShorthand = function(shorthand, data, config, theme) {
var c = consts.shorthand,
split = shorthand.split(c.delim),
marktype = split.shift().split(c.assign)[1].trim(),
enc = vlenc.fromShorthand(split);
return new Encoding({
data: data,
marktype: marktype,
encoding: enc,
config: config,
filter: []
}, theme);
};
Encoding.fromSpec = function(spec, theme) {
return new Encoding(spec, theme);
};
proto.toShorthand = function() {
var c = consts.shorthand;
return 'mark' + c.assign + this._marktype +
c.delim + vlenc.shorthand(this._enc);
};
Encoding.shorthand = function (spec) {
var c = consts.shorthand;
return 'mark' + c.assign + spec.marktype +
c.delim + vlenc.shorthand(spec.enc);
};
Encoding.specFromShorthand = function(shorthand, data, config, excludeConfig) {
return Encoding.fromShorthand(shorthand, data, config).toSpec(excludeConfig);
};
proto.toSpec = function(excludeConfig, excludeData) {
var enc = util.duplicate(this._enc),
spec;
spec = {
marktype: this._marktype,
encoding: enc,
filter: this._filter
};
if (!excludeConfig) {
spec.config = util.duplicate(this._config);
}
if (!excludeData) {
spec.data = util.duplicate(this._data);
}
// remove defaults
var defaults = schema.instantiate();
return schema.util.subtract(spec, defaults);
};
proto.marktype = function() {

@@ -84,4 +134,4 @@ return this._marktype;

return f + 'bin_' + this._enc[et].name;
} else if (!nofn && this._enc[et].aggr) {
return f + this._enc[et].aggr + '_' + this._enc[et].name;
} else if (!nofn && this._enc[et].aggregate) {
return f + this._enc[et].aggregate + '_' + this._enc[et].name;
} else if (!nofn && this._enc[et].fn) {

@@ -109,3 +159,3 @@ return f + this._enc[et].fn + '_' + this._enc[et].name;

}
var fn = this._enc[et].aggr || this._enc[et].fn || (this._enc[et].bin && "bin");
var fn = this._enc[et].aggregate || this._enc[et].fn || (this._enc[et].bin && "bin");
if (fn) {

@@ -141,4 +191,4 @@ return fn.toUpperCase() + '(' + this._enc[et].name + ')';

proto.aggr = function(et) {
return this._enc[et].aggr;
proto.aggregate = function(et) {
return this._enc[et].aggregate;
};

@@ -176,4 +226,5 @@

if ((!sort || sort.length===0) &&
// FIXME
Encoding.toggleSort.support({enc:this._enc}, stats, true) && //HACK
this.config('toggleSort') === 'Q'
this.config('toggleSort') === Q
) {

@@ -185,3 +236,3 @@ var qField = isType(enc.x, O) ? enc.y : enc.x;

name: qField.name,
aggr: qField.aggr,
aggregate: qField.aggregate,
type: qField.type,

@@ -307,54 +358,2 @@ reverse: true

proto.toSpec = function(excludeConfig, excludeData) {
var enc = util.duplicate(this._enc),
spec;
spec = {
marktype: this._marktype,
enc: enc,
filter: this._filter
};
if (!excludeConfig) {
spec.config = util.duplicate(this._config);
}
if (!excludeData) {
spec.data = util.duplicate(this._data);
}
// remove defaults
var defaults = schema.instantiate();
return schema.util.subtract(spec, defaults);
};
proto.toShorthand = function() {
var c = consts.shorthand;
return 'mark' + c.assign + this._marktype +
c.delim + vlenc.shorthand(this._enc);
};
Encoding.shorthand = function (spec) {
var c = consts.shorthand;
return 'mark' + c.assign + spec.marktype +
c.delim + vlenc.shorthand(spec.enc);
};
Encoding.fromShorthand = function(shorthand, data, config, theme) {
var c = consts.shorthand,
split = shorthand.split(c.delim),
marktype = split.shift().split(c.assign)[1].trim(),
enc = vlenc.fromShorthand(split);
return new Encoding(marktype, enc, data, config, null, theme);
};
Encoding.specFromShorthand = function(shorthand, data, config, excludeConfig) {
return Encoding.fromShorthand(shorthand, data, config).toSpec(excludeConfig);
};
Encoding.fromSpec = function(spec, theme) {
return new Encoding(spec.marktype, spec.enc, spec.data, spec.config, spec.filter, theme);
};
Encoding.transpose = function(spec) {

@@ -373,3 +372,3 @@ var oldenc = spec.enc,

spec.config = spec.config || {};
spec.config.toggleSort = spec.config.toggleSort === 'Q' ? 'O' :'Q';
spec.config.toggleSort = spec.config.toggleSort === Q ? O : Q;
return spec;

@@ -382,3 +381,3 @@ };

var enc = spec.enc;
return enc.x.type === 'O' ? 'x' : 'y';
return enc.x.type === O ? 'x' : 'y';
};

@@ -385,0 +384,0 @@

@@ -5,2 +5,4 @@ 'use strict';

require('./globals');
var consts = require('./consts'),

@@ -16,3 +18,3 @@ c = consts.shorthand,

var c = consts.shorthand;
return (f.aggr ? f.aggr + c.func : '') +
return (f.aggregate ? f.aggregate + c.func : '') +
(f.fn ? f.fn + c.func : '') +

@@ -36,8 +38,8 @@ (f.bin ? 'bin' + c.func : '') +

// check aggregate type
for (i in schema.aggr.enum) {
var a = schema.aggr.enum[i];
for (i in schema.aggregate.enum) {
var a = schema.aggregate.enum[i];
if (o.name.indexOf(a + '_') === 0) {
o.name = o.name.substr(a.length + 1);
if (a == 'count' && o.name.length === 0) o.name = '*';
o.aggr = a;
o.aggregate = a;
break;

@@ -76,3 +78,3 @@ }

vlfield.order.type = function(field) {
if (field.aggr==='count') return 4;
if (field.aggregate==='count') return 4;
return typeOrder[field.type];

@@ -133,3 +135,3 @@ };

vlfield.count = function() {
return {name:'*', aggr: 'count', type:'Q', displayName: vlfield.count.displayName};
return {name:'*', aggregate: 'count', type: Q, displayName: vlfield.count.displayName};
};

@@ -140,3 +142,3 @@

vlfield.isCount = function(field) {
return field.aggr === 'count';
return field.aggregate === 'count';
};

@@ -165,3 +167,3 @@

}
if (field.aggr) {
if (field.aggregate) {
return 1;

@@ -168,0 +170,0 @@ }

// Package of defining Vega-lite Specification's json schema
"use strict";
'use strict';
require('../globals');
var schema = module.exports = {},
util = require('../util');
util = require('../util'),
toMap = util.toMap;

@@ -14,3 +17,3 @@ schema.util = require('./schemautil');

schema.aggr = {
schema.aggregate = {
type: 'string',

@@ -24,3 +27,3 @@ enum: ['avg', 'sum', 'median', 'min', 'max', 'count'],

},
supportedTypes: {'Q': true, 'O': true, 'T': true, '': true}
supportedTypes: toMap([Q, O, T, ''])
};

@@ -43,3 +46,3 @@ schema.band = {

schema.getSupportedRole = function(encType) {
return schema.schema.properties.enc.properties[encType].supportedRole;
return schema.schema.properties.encoding.properties[encType].supportedRole;
};

@@ -54,3 +57,3 @@

enum: schema.timefns,
supportedTypes: {'T': true}
supportedTypes: toMap([T])
};

@@ -64,3 +67,3 @@

default: 'linear',
supportedTypes: {'Q': true}
supportedTypes: toMap([Q])
};

@@ -92,3 +95,3 @@

},
supportedTypes: {'Q': true} // TODO: add 'O' after finishing #81
supportedTypes: toMap([Q]) // TODO: add O after finishing #81
};

@@ -101,5 +104,5 @@

type: 'string',
enum: ['O', 'Q', 'T']
enum: [O, Q, T]
},
aggr: schema.aggr,
aggregate: schema.aggregate,
fn: schema.fn,

@@ -114,3 +117,3 @@ bin: bin,

default: false,
supportedTypes: {'Q': true, 'T': true}
supportedTypes: toMap([Q, T])
},

@@ -121,3 +124,3 @@ zero: {

default: true,
supportedTypes: {'Q': true, 'T': true}
supportedTypes: toMap([Q, T])
},

@@ -127,3 +130,3 @@ nice: {

enum: ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'],
supportedTypes: {'T': true}
supportedTypes: toMap([T])
}

@@ -143,10 +146,10 @@ }

type: 'string',
enum: ['O','Q', 'T'] // ordinal-only field supports Q when bin is applied and T when fn is applied.
enum: [O, Q, T] // ordinal-only field supports Q when bin is applied and T when fn is applied.
},
fn: schema.fn,
bin: bin,
aggr: {
aggregate: {
type: 'string',
enum: ['count'],
supportedTypes: {'O': true}
supportedTypes: toMap([O])
}

@@ -202,8 +205,8 @@ }

type: 'object',
supportedTypes: {'O': true},
required: ['name', 'aggr'],
supportedTypes: toMap([O]),
required: ['name', 'aggregate'],
name: {
type: 'string'
},
aggr: {
aggregate: {
type: 'string',

@@ -524,3 +527,3 @@ enum: ['avg', 'sum', 'min', 'max', 'count']

type: 'string',
default: 'O'
default: O
},

@@ -615,7 +618,7 @@

type: 'object',
required: ['marktype', 'enc', 'data'],
required: ['marktype', 'encoding', 'data'],
properties: {
data: data,
marktype: schema.marktype,
enc: {
encoding: {
type: 'object',

@@ -640,3 +643,3 @@ properties: {

schema.encTypes = util.keys(schema.schema.properties.enc.properties);
schema.encTypes = util.keys(schema.schema.properties.encoding.properties);

@@ -643,0 +646,0 @@ /** Instantiate a verbose vl spec from the schema */

@@ -13,3 +13,3 @@ 'use strict';

encoding = Encoding.fromSpec({
enc: {
encoding: {
x: {name: fieldName, type: 'T', fn: fn}

@@ -16,0 +16,0 @@ }

@@ -10,11 +10,11 @@ 'use strict';

var encoding = Encoding.fromSpec({
enc: {
encoding: {
x: {name: 'foo', type: 'O', sort: [{
name: 'bar', aggr: 'avg'
name: 'bar', aggregate: 'avg'
}]},
y: {name: 'bar', type: 'Q'},
color: {name: 'baz', type: 'O', sort: [{
name: 'bar', aggr: 'sum'
name: 'bar', aggregate: 'sum'
}, {
name: 'foo', aggr: 'max', reverse: true
name: 'foo', aggregate: 'max', reverse: true
}]}

@@ -21,0 +21,0 @@ }

'use strict';
var expect = require('chai').expect;
var fixtures = require('../fixtures').stack;

@@ -17,20 +18,3 @@ var compile = require('../../src/compile/compile'),

var spec_stackBinY = {
"marktype": "bar",
"enc": {
"x": {"type": "Q","name": "Cost__Other","aggr": "avg"},
"y": {"bin": true,"type": "Q","name": "Cost__Total_$"},
"color": {"type": "O","name": "Effect__Amount_of_damage"}
}
};
var spec_stackBinX = {
"marktype": "bar",
"enc": {
"y": {"type": "Q","name": "Cost__Other","aggr": "avg"},
"x": {"bin": true,"type": "Q","name": "Cost__Total_$"},
"color": {"type": "O","name": "Effect__Amount_of_damage"}
}
};
var stats = {

@@ -58,3 +42,3 @@ 'Cost__Total_$': {

it('should put stack on y', function () {
var vgSpec = compile(spec_stackBinX, stats);
var vgSpec = compile(fixtures.binX, stats);

@@ -83,3 +67,3 @@ var tableData = vgSpec.data.filter(function(data) {

it('should put stack on x', function () {
var vgSpec = compile(spec_stackBinY, stats);
var vgSpec = compile(fixtures.binY, stats);

@@ -86,0 +70,0 @@ var tableData = vgSpec.data.filter(function(data) {

@@ -12,3 +12,3 @@ 'use strict';

encoding = Encoding.fromSpec({
enc: {
encoding: {
x: {name: fieldName, type: 'T', fn: fn}

@@ -15,0 +15,0 @@ }

@@ -20,3 +20,3 @@ 'use strict';

marktype: 'point',
enc: {
encoding: {
y: {name: 'Q', type:'Q'},

@@ -23,0 +23,0 @@ x: {name: 'T', type:'T'},

var f = {};
// BARS
f.bars = {};

@@ -7,5 +9,5 @@

"marktype": "bar",
"enc": {
encoding: {
"x": {"bin": {"maxbins": 15},"type": "Q","name": "IMDB_Rating"},
"y": {"scale": {"type": "log"},"type": "Q","name": "US_Gross","aggr": "avg"}
"y": {"scale": {"type": "log"},"type": "Q","name": "US_Gross","aggregate": "avg"}
},

@@ -18,5 +20,5 @@ "config": {"singleHeight": 400,"singleWidth": 400,"largeBandMaxCardinality": 20},

"marktype": "bar",
"enc": {
encoding: {
"y": {"bin": {"maxbins": 15},"type": "Q","name": "IMDB_Rating"},
"x": {"scale": {"type": "log"},"type": "Q","name": "US_Gross","aggr": "avg"}
"x": {"scale": {"type": "log"},"type": "Q","name": "US_Gross","aggregate": "avg"}
},

@@ -29,3 +31,3 @@ "config": {"singleHeight": 400,"singleWidth": 400,"largeBandMaxCardinality": 20},

"marktype": "bar",
"enc": {"x": {"type": "Q","name": "US_Gross","aggr": "sum"}},
encoding: {"x": {"type": "Q","name": "US_Gross","aggregate": "sum"}},
"config": {"singleHeight": 400,"singleWidth": 400,"largeBandMaxCardinality": 20},

@@ -38,3 +40,3 @@ "data": {"url": "data/movies.json"}

"marktype": "bar",
"enc": {"y": {"type": "Q","name": "US_Gross","aggr": "sum"}},
encoding: {"y": {"type": "Q","name": "US_Gross","aggregate": "sum"}},
"config": {"singleHeight": 400,"singleWidth": 400,"largeBandMaxCardinality": 20},

@@ -44,2 +46,23 @@ "data": {"url": "data/movies.json"}

module.exports = f;
// STACK
f.stack = {};
f.stack.binY = {
"marktype": "bar",
"encoding": {
"x": {"type": "Q","name": "Cost__Other","aggregate": "avg"},
"y": {"bin": true,"type": "Q","name": "Cost__Total_$"},
"color": {"type": "O","name": "Effect__Amount_of_damage"}
}
};
f.stack.binX = {
"marktype": "bar",
"encoding": {
"y": {"type": "Q","name": "Cost__Other","aggregate": "avg"},
"x": {"bin": true,"type": "Q","name": "Cost__Total_$"},
"color": {"type": "O","name": "Effect__Amount_of_damage"}
}
};
module.exports = f;

@@ -31,3 +31,3 @@ 'use strict';

it('field def should have supportedMarktypes', function() {
var encProps = specSchema.properties.enc.properties;
var encProps = specSchema.properties.encoding.properties;
for (var k in encProps) {

@@ -55,3 +55,3 @@ assert.notEqual(encProps[k].supportedMarktypes, undefined);

marktype: 'point',
enc: {
encoding: {
x: { name: 'dsp', type: 'Q', scale: {type: 'linear'}

@@ -69,3 +69,3 @@ },

marktype: 'point',
enc: {
encoding: {
x: { name: 'dsp', type: 'Q' },

@@ -72,0 +72,0 @@ color: { name: 'cyl', type: 'O' }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc