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.11 to 0.6.12

test/compile/marks.spec.js

11

gulp/serve.js

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

gulp.task('serve', ['copydl', 'bundle', 'watch-schema', 'watch-test'], function() {
browserSync({
server: {
baseDir: './'
}
});
browserSync({
server: {
baseDir: './'
},
browser: 'google chrome'
});
});
{
"name": "vega-lite",
"author": "Jeffrey Heer, Dominik Moritz, Kanit \"Ham\" Wongsuphasawat",
"version": "0.6.11",
"version": "0.6.12",
"collaborators": [

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

@@ -98,42 +98,43 @@ 'use strict';

// x
// x's and width
if (e.isMeasure(X)) {
p.x = {scale: X, field: e.field(X)};
if (e.isDimension(Y)) {
p.x2 = {scale: X, value: e.scale(X).type === 'log' ? 1 : 0};
if (!e.has(Y) || e.isDimension(Y)) {
p.x2 = {value: 0};
}
} else if (e.has(X)) { // is ordinal
p.xc = {scale: X, field: e.field(X)};
} else {
// TODO add single bar offset
p.xc = {value: 0};
if (e.has(X)) { // is ordinal
p.xc = {scale: X, field: e.field(X)};
} else {
p.x = {value: 0, offset: e.config('singleBarOffset')};
}
}
// width
if (!p.x2) {
if (!e.has(X) || e.isOrdinalScale(X)) { // no X or X is ordinal
if (e.has(SIZE)) {
p.width = {scale: SIZE, field: e.field(SIZE)};
} else {
p.width = {
value: e.bandSize(X, layout.x.useSmallBand),
offset: -1
};
}
} else { // X is Quant or Time Scale
p.width = {value: 2};
}
}
// y
// y's & height
if (e.isMeasure(Y)) {
p.y = {scale: Y, field: e.field(Y)};
p.y2 = {scale: Y, value: e.scale(Y).type === 'log' ? 1 : 0};
} else if (e.has(Y)) { // is ordinal
p.yc = {scale: Y, field: e.field(Y)};
p.y2 = {group: "height"};
} else {
// TODO add single bar offset
p.yc = {group: 'height'};
}
// width
if (!e.has(X) || e.isOrdinalScale(X)) { // no X or X is ordinal
if (e.has(SIZE)) {
p.width = {scale: SIZE, field: e.field(SIZE)};
if (e.has(Y)) { // is ordinal
p.yc = {scale: Y, field: e.field(Y)};
} else {
p.width = {
value: e.bandSize(X, layout.x.useSmallBand),
offset: -1
};
p.y2 = {group: 'height', offset: -e.config('singleBarOffset')};
}
} else { // X is Quant or Time Scale
p.width = {value: 2};
}
// height
if (!e.has(Y) || e.isOrdinalScale(Y)) { // no Y or Y is ordinal
if (e.has(SIZE)) {

@@ -147,6 +148,6 @@ p.height = {scale: SIZE, field: e.field(SIZE)};

}
} else { // Y is Quant or Time Scale
p.height = {value: 2};
}
// fill

@@ -153,0 +154,0 @@ if (e.has(COLOR)) {

@@ -55,11 +55,2 @@ 'use strict';

if (encoding.bin(name)) {
// TODO: add includeEmptyConfig here
if (opt.stats) {
var bins = util.getbins(opt.stats[encoding.fieldName(name)], encoding.bin(name).maxbins);
var domain = util.range(bins.start, bins.stop, bins.step);
return name === Y ? domain.reverse() : domain;
}
}
return name == opt.stack ?

@@ -66,0 +57,0 @@ {

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

!((encType === X || encType === Y) &&
vlfield.isOrdinalScale(field, true))
vlfield.isOrdinalScale(field))
) {

@@ -49,0 +49,0 @@ numPoints *= encoding.cardinality(encType, stats);

@@ -9,9 +9,2 @@ 'use strict';

consts.dataTypes = {'O': O, 'Q': Q, 'T': T};
consts.dataTypeNames = ['O', 'Q', 'T'].reduce(function(r, x) {
r[consts.dataTypes[x]] = x;
return r;
},{});
consts.shorthand = {

@@ -18,0 +11,0 @@ delim: '|',

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

vlenc.fromShorthand = function(shorthand, convertType) {
vlenc.fromShorthand = function(shorthand) {
var enc = util.isArray(shorthand) ? shorthand : shorthand.split(c.delim);

@@ -97,5 +97,5 @@ return enc.reduce(function(m, e) {

m[enctype] = vlfield.fromShorthand(field, convertType);
m[enctype] = vlfield.fromShorthand(field);
return m;
}, {});
};

@@ -23,7 +23,2 @@ 'use strict';

// type to bitcode
for (var e in defaults.enc) {
defaults.enc[e].type = consts.dataTypes[defaults.enc[e].type];
}
var specExtended = schema.util.merge(defaults, theme || {}, spec) ;

@@ -174,6 +169,4 @@

enc = this._enc,
isType = vlfield.isType.byCode;
isType = vlfield.isType;
// console.log('sort:', sort, 'support:', Encoding.toggleSort.support({enc:this._enc}, stats) , 'toggle:', this.config('toggleSort'))
if ((!sort || sort.length===0) &&

@@ -237,17 +230,14 @@ Encoding.toggleSort.support({enc:this._enc}, stats, true) && //HACK

Encoding.isType = function (fieldDef, type) {
// FIXME vlfield.isType
return (fieldDef.type & type) > 0;
};
Encoding.isType = vlfield.isType;
Encoding.isOrdinalScale = function(encoding, encType) {
return vlfield.isOrdinalScale(encoding.enc(encType), true);
return vlfield.isOrdinalScale(encoding.enc(encType));
};
Encoding.isDimension = function(encoding, encType) {
return vlfield.isDimension(encoding.enc(encType), true);
return vlfield.isDimension(encoding.enc(encType));
};
Encoding.isMeasure = function(encoding, encType) {
return vlfield.isMeasure(encoding.enc(encType), true);
return vlfield.isMeasure(encoding.enc(encType));
};

@@ -292,3 +282,3 @@

proto.cardinality = function(encType, stats) {
return vlfield.cardinality(this.enc(encType), stats, this.config('filterNull'), true);
return vlfield.cardinality(this.enc(encType), stats, this.config('filterNull'));
};

@@ -318,7 +308,2 @@

// convert type's bitcode to type name
for (var e in enc) {
enc[e].type = consts.dataTypeNames[enc[e].type];
}
spec = {

@@ -359,3 +344,3 @@ marktype: this._marktype,

marktype = split.shift().split(c.assign)[1].trim(),
enc = vlenc.fromShorthand(split, true);
enc = vlenc.fromShorthand(split);

@@ -370,10 +355,3 @@ return new Encoding(marktype, enc, data, config, null, theme);

Encoding.fromSpec = function(spec, theme) {
var enc = util.duplicate(spec.enc || {});
//convert type from string to bitcode (e.g, O=1)
for (var e in enc) {
enc[e].type = consts.dataTypes[enc[e].type];
}
return new Encoding(spec.marktype, enc, spec.data, spec.config, spec.filter, theme);
return new Encoding(spec.marktype, spec.enc, spec.data, spec.config, spec.filter, theme);
};

@@ -399,4 +377,4 @@

Encoding.toggleSort.direction = function(spec, useTypeCode) {
if (!Encoding.toggleSort.support(spec, useTypeCode)) { return; }
Encoding.toggleSort.direction = function(spec) {
if (!Encoding.toggleSort.support(spec)) { return; }
var enc = spec.enc;

@@ -410,5 +388,5 @@ return enc.x.type === 'O' ? 'x' : 'y';

Encoding.toggleSort.support = function(spec, stats, useTypeCode) {
Encoding.toggleSort.support = function(spec, stats) {
var enc = spec.enc,
isType = vlfield.isType.get(useTypeCode);
isType = vlfield.isType;

@@ -421,4 +399,4 @@ if (vlenc.has(enc, ROW) || vlenc.has(enc, COL) ||

return ( isType(enc.x, O) && vlfield.isMeasure(enc.y, useTypeCode)) ? 'x' :
( isType(enc.y, O) && vlfield.isMeasure(enc.x, useTypeCode)) ? 'y' : false;
return ( isType(enc.x, O) && vlfield.isMeasure(enc.y)) ? 'x' :
( isType(enc.y, O) && vlfield.isMeasure(enc.x)) ? 'y' : false;
};

@@ -425,0 +403,0 @@

@@ -18,4 +18,3 @@ 'use strict';

(f.bin ? 'bin' + c.func : '') +
(f.name || '') + c.type +
(consts.dataTypeNames[f.type] || f.type);
(f.name || '') + c.type + f.type;
};

@@ -28,7 +27,7 @@

vlfield.fromShorthand = function(shorthand, convertType) {
vlfield.fromShorthand = function(shorthand) {
var split = shorthand.split(c.type), i;
var o = {
name: split[0].trim(),
type: convertType ? consts.dataTypes[split[1].trim()] : split[1].trim()
type: split[1].trim()
};

@@ -96,20 +95,6 @@

// FIXME refactor
vlfield.isType = function (fieldDef, type) {
return (fieldDef.type & type) > 0;
var isType = vlfield.isType = function (fieldDef, type) {
return fieldDef.type === type;
};
vlfield.isType.byCode = vlfield.isType;
vlfield.isType.byName = function (field, type) {
return field.type === consts.dataTypeNames[type];
};
function getIsType(useTypeCode) {
return useTypeCode ? vlfield.isType.byCode : vlfield.isType.byName;
}
vlfield.isType.get = getIsType; //FIXME
/*

@@ -119,4 +104,3 @@ * Most fields that use ordinal scale are dimensions.

*/
vlfield.isOrdinalScale = function(field, useTypeCode /*optional*/) {
var isType = getIsType(useTypeCode);
vlfield.isOrdinalScale = function(field) {
return isType(field, O) || field.bin ||

@@ -126,4 +110,3 @@ ( isType(field, T) && field.fn && time.isOrdinalFn(field.fn) );

function isDimension(field, useTypeCode /*optional*/) {
var isType = getIsType(useTypeCode);
function isDimension(field) {
return isType(field, O) || !!field.bin ||

@@ -138,8 +121,8 @@ ( isType(field, T) && !!field.fn );

*/
vlfield.isDimension = function(field, useTypeCode /*optional*/) {
return field && isDimension(field, useTypeCode);
vlfield.isDimension = function(field) {
return field && isDimension(field);
};
vlfield.isMeasure = function(field, useTypeCode) {
return field && !isDimension(field, useTypeCode);
vlfield.isMeasure = function(field) {
return field && !isDimension(field);
};

@@ -165,8 +148,7 @@

*/
vlfield.cardinality = function(field, stats, filterNull, useTypeCode) {
vlfield.cardinality = function(field, stats, filterNull) {
// FIXME need to take filter into account
var stat = stats[field.name];
var isType = getIsType(useTypeCode),
type = useTypeCode ? consts.dataTypeNames[field.type] : field.type;
var type = field.type;

@@ -173,0 +155,0 @@ filterNull = filterNull || {};

@@ -22,4 +22,4 @@ 'use strict';

g.O = 1;
g.Q = 2;
g.T = 4;
g.O = 'O';
g.Q = 'Q';
g.T = 'T';

@@ -16,7 +16,7 @@ // Package of defining Vega-lite Specification's json schema

type: 'string',
enum: ['avg', 'sum', 'min', 'max', 'count'],
enum: ['avg', 'sum', 'median', 'min', 'max', 'count'],
supportedEnums: {
Q: ['avg', 'sum', 'min', 'max', 'count'],
Q: ['avg', 'median', 'sum', 'min', 'max', 'count'],
O: [],
T: ['avg', 'min', 'max'],
T: ['avg', 'median', 'min', 'max'],
'': ['count']

@@ -578,2 +578,7 @@ },

},
singleBarOffset: {
type: 'integer',
default: 5,
minimum: 0
},

@@ -580,0 +585,0 @@ // scales

Sorry, the diff of this file is not supported yet

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