Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-encode

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-encode - npm Package Compare versions

Comparing version 1.0.0-beta.13 to 1.0.0-beta.14

67

build/vega-encode.js

@@ -815,5 +815,6 @@ (function (global, factory) {

field = _.field || vegaUtil.one,
offset = _.offset,
groups, group, i, j, n, m,
max, off, scale$$1, t, a, b, v;
stack = _.offset === Center ? stackCenter
: _.offset === Normalize ? stackNormalize
: stackZero,
groups, i, n, max;

@@ -825,15 +826,3 @@ // partition, sum, and sort the stack groups

for (i=0, n=groups.length, max=groups.max; i<n; ++i) {
group = groups[i];
off = offset === Center ? (max - group.sum)/2 : 0;
scale$$1 = offset === Normalize ? (1/group.sum) : 1;
// set stack coordinates for each datum in group
for (b=off, v=0, j=0, m=group.length; j<m; ++j) {
t = group[j];
a = b; // use previous value for start point
v += field(t);
b = scale$$1 * v + off; // compute end point
t[y0] = a;
t[y1] = b;
}
stack(groups[i], max, field, y0, y1);
}

@@ -844,2 +833,46 @@

function stackCenter(group, max, field, y0, y1) {
var last = (max - group.sum) / 2,
m = group.length,
j = 0, t;
for (; j<m; ++j) {
t = group[j];
t[y0] = last;
t[y1] = (last += Math.abs(field(t)));
}
}
function stackNormalize(group, max, field, y0, y1) {
var scale$$1 = 1 / group.sum,
last = 0,
m = group.length,
j = 0, v = 0, t;
for (; j<m; ++j) {
t = group[j];
t[y0] = last;
t[y1] = last = scale$$1 * (v += Math.abs(field(t)));
}
}
function stackZero(group, max, field, y0, y1) {
var lastPos = 0,
lastNeg = 0,
m = group.length,
j = 0, v, t;
for (; j<m; ++j) {
t = group[j];
v = field(t);
if (v < 0) {
t[y0] = lastNeg;
t[y1] = (lastNeg += v);
} else {
t[y0] = lastPos;
t[y1] = (lastPos += v);
}
}
}
function partition(data, groupby, sort, field) {

@@ -866,3 +899,3 @@ var groups = [],

for (i=0, s=0, n=g.length; i<n; ++i) {
s += field(g[i]);
s += Math.abs(field(g[i]));
}

@@ -869,0 +902,0 @@ g.sum = s;

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-util"),require("d3-format"),require("vega-scale"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-format","vega-scale","d3-array","d3-interpolate"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,t,r,a,i,o){"use strict";function u(e,n){return e.ticks?e.ticks(n):e.domain()}function s(e,n,t){var r=e.tickFormat?e.tickFormat(n,t):String;return e.type===ne?l(r,f(t)):r}function l(e,n){return function(t){return e(t)?n(t):""}}function f(e){var n=r.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return c(r.format(n),r.format(".1f")(1)[1])}return r.format(n)}function c(e,n){return function(t){var r,a,i=e(t),o=i.indexOf(n);if(o<0)return i;for(r=d(i,o),a=r<i.length?i.slice(r):"";--r>o;)if("0"!==i[r]){++r;break}return i.slice(0,r)+a}}function d(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if(t=e.charCodeAt(r),t>=48&&t<=57)return r+1}function m(e){n.Transform.call(this,[],e)}function p(e){n.Transform.call(this,null,e)}function h(){return n.ingest({})}function v(e){return e.exit}function g(e){n.Transform.call(this,null,e)}function y(e,n,t){if(t)return e.domain();var r=ge[e.type];return r?r(e):u(e,n)}function M(e){var n=e.domain(),r=n[0],a=t.peek(n),i=e.range().length,o=new Array(i),u=0;for(o[0]=r;++u<i;)o[u]=(u*a-(u-i)*r)/i;return o.max=a,o}function x(e){var n=e.domain(),r=[n[0]].concat(e.quantiles());return r.max=t.peek(n),r}function S(e){var n=[-(1/0)].concat(e.domain());return n.max=+(1/0),n}function k(e){var n=e.domain();return n.max=n.pop(),n}function O(e,n){return ge[e.type]?A(n):E(n)}function A(e){return function(n,t,r){var a=r[t+1]||r.max||+(1/0),i=b(n,e),o=b(a,e);return i&&o?i+"–"+o:o?"< "+o:"≥ "+i}}function b(e,n){return isFinite(e)?n(e):null}function E(e){return function(n){return e(n)}}function T(e){n.Transform.call(this,[],e)}function w(e){return e.source.x}function D(e){return e.source.y}function F(e){return e.target.x}function R(e){return e.target.y}function z(e){n.Transform.call(this,{},e)}function C(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function L(e,n,t,r){return C(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))}function q(e,n,t,r){var a=t-e,i=r-n,o=.2*(a+i),u=.2*(i-a);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function _(e,n,t,r){return q(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))}function I(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t}function N(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r}function P(e,n,t,r){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*a+","+n*i+"A"+n+","+n+" 0 0,"+(s?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u}function U(e,n,t,r){var a=(e+t)/2;return"M"+e+","+n+"C"+a+","+n+" "+a+","+r+" "+t+","+r}function X(e,n,t,r){var a=(n+r)/2;return"M"+e+","+n+"C"+e+","+a+" "+t+","+a+" "+t+","+r}function Y(e,n,t,r){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=(n+r)/2;return"M"+n*a+","+n*i+"C"+s*a+","+s*i+" "+s*o+","+s*u+" "+r*o+","+r*u}function j(e){n.Transform.call(this,null,e)}function G(e){n.Transform.call(this,null,e),this.modified(!0)}function H(e,n,t){var r=J(e,n.domainRaw);if(r>-1)return r;var a,i,o=n.domain,u=n.zero||void 0===n.zero&&Oe[e.type];return o?((u||null!=n.domainMin||null!=n.domainMax||null!=n.domainMid)&&(a=(o=o.slice()).length-1||1,u&&(o[0]>0&&(o[0]=0),o[a]<0&&(o[a]=0)),null!=n.domainMin&&(o[0]=n.domainMin),null!=n.domainMax&&(o[a]=n.domainMax),null!=n.domainMid&&(i=n.domainMid,(i<o[0]||i>o[a])&&t.warn("Scale domainMid exceeds domain min or max.",i),o.splice(a,0,i))),e.domain(o),n.nice&&e.nice&&e.nice(n.nice!==!0&&+n.nice||null),o.length):0}function J(e,n){return n?(e.domain(n),n.length):-1}function V(e,n,r){var i=n.round||!1,u=n.range;if(null!=n.rangeStep)u=B(e.type,n,r);else if(n.scheme){if(u=W(e.type,n,r),t.isFunction(u))return e.interpolator(u)}else if(u&&e.type===me)return e.interpolator(o.interpolateRgbBasis(Q(u,n.reverse)));u&&n.interpolate&&e.interpolate?e.interpolate(a.interpolate(n.interpolate,n.interpolateGamma)):t.isFunction(e.round)?e.round(i):t.isFunction(e.rangeRound)&&e.interpolate(i?o.interpolateRound:o.interpolate),u&&e.range(Q(u,n.reverse))}function B(e,n,r){e!==ae&&e!==ie&&t.error("Only band and point scales support rangeStep.");var i=(null!=n.paddingOuter?n.paddingOuter:n.padding)||0,o=e===ie?1:(null!=n.paddingInner?n.paddingInner:n.padding)||0;return[0,n.rangeStep*a.bandSpace(r,o,i)]}function W(e,n,r){var i,o=n.scheme.toLowerCase(),u=a.scheme(o),s=n.schemeExtent;return u||t.error("Unrecognized scheme name: "+n.scheme),r=e===fe?r+1:e===de?r-1:e===se||e===le?+n.schemeCount||ke:r,e===me?K(u,s,n.reverse):!s&&(i=a.scheme(o+"-"+r))?i:t.isFunction(u)?Z(K(u,s),r):e===ue?u:u.slice(0,r)}function K(e,n,r){return t.isFunction(e)&&(n||r)?a.interpolateRange(e,Q(n||[0,1],r)):e}function Q(e,n){return n?e.slice().reverse():e}function Z(e,n){for(var t=new Array(n),r=n-1||1,a=0;a<n;++a)t[a]=e(a/r);return t}function $(e){n.Transform.call(this,null,e)}function ee(e,n,t,r){var a,i,o,u,s,l,f,c,d,m=[],p=function(e){return e(s)};if(null==n)m.push(e.slice());else for(a={},i=0,o=e.length;i<o;++i)s=e[i],l=n.map(p),f=a[l]||(m.push(a[l]=[]),a[l]),f.push(s);for(l=0,d=0,u=m.length;l<u;++l){for(f=m[l],i=0,c=0,o=f.length;i<o;++i)c+=r(f[i]);f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}var ne="log",te="pow",re="sqrt",ae="band",ie="point",oe="linear",ue="ordinal",se="quantile",le="quantize",fe="threshold",ce="bin-linear",de="bin-ordinal",me="sequential",pe=t.inherits(m,n.Transform);pe.transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var r=t.fork(t.NO_SOURCE|t.NO_FIELDS),a=this.value,i=e.scale,o=e.count,l=e.format||s(i,o,e.formatSpecifier),f=e.values||u(i,o);return a&&(r.rem=a),a=f.map(function(e){return n.ingest({value:e,label:l(e)})}),e.extra&&a.push(n.ingest({extra:{value:a[0].value},label:""})),r.source=r.add=this.value=a,r};var he=t.inherits(p,n.Transform);he.transform=function(e,r){var a=r.dataflow,i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=e.item||h,u=e.key||n.tupleid,s=this.value;return s||(r=r.addAll(),this.value=s=t.fastmap().test(v),s.lookup=function(e){return s.get(u(e))}),(e.modified("key")||r.modified(u))&&t.error("DataJoin does not support modified key function or fields."),r.visit(r.ADD,function(e){var n=u(e),t=s.get(n);t?(t.exit?(--s.empty,i.add):i.mod).push(t):(s.set(n,t=o(e)),i.add.push(t)),t.datum=e,t.exit=!1}),r.visit(r.MOD,function(e){var n=u(e),t=s.get(n);t&&(t.datum=e,i.mod.push(t))}),r.visit(r.REM,function(e){var n=u(e),t=s.get(n);e!==t.datum||t.exit||(i.rem.push(t),t.exit=!0,++s.empty)}),e.clean&&s.empty>a.cleanThreshold&&a.runAfter(s.clean),i};var ve=t.inherits(g,n.Transform);ve.transform=function(e,n){var r=n.fork(n.ADD_REM),a=n.encode,i="enter"===a,o=e.encoders.update||t.falsy,u=e.encoders.enter||t.falsy,s=e.encoders.exit||t.falsy,l=(a&&!i?e.encoders[a]:o)||t.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){u(n,e),o(n,e),l!==t.falsy&&l!==o&&l(n,e)}),r.modifies(u.output),r.modifies(o.output),l!==t.falsy&&l!==o&&r.modifies(l.output)),n.changed(n.REM)&&s!==t.falsy&&(n.visit(n.REM,function(n){s(n,e)}),r.modifies(s.output)),i||l!==t.falsy){var f=n.MOD|(e.modified()?n.REFLOW:0);i?(n.visit(f,function(n){var t=u(n,e);(l(n,e)||t)&&r.mod.push(n)}),r.mod.length&&r.modifies(u.output)):n.visit(f,function(n){l(n,e)&&r.mod.push(n)}),r.mod.length&&r.modifies(l.output)}return r};var ge={};ge[se]=x,ge[le]=M,ge[fe]=S,ge[ce]=k,ge[de]=k;var ye=t.inherits(T,n.Transform);ye.transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=0,u=this.value,l="gradient"===e.type,f=e.scale,c=null==e.count?5:e.count,d=e.format||s(f,c,e.formatSpecifier),m=e.values||y(f,c,l);if(d=O(f,d),u&&(i.rem=u),l)var p=e.values?f.domain():m,h=a.scaleFraction(f,p[0],t.peek(p));else{var v,g=e.size;t.isFunction(g)?(e.values||0!==f(m[0])||(m=m.slice(1)),v=m.reduce(function(n,t){return Math.max(n,g(t,e))},0)):g=t.constant(v=g||8)}return u=m.map(function(t,r){var a=n.ingest({index:r,label:d(t,r,m),value:t});return l?a.perc=h(t):(a.offset=v,a.size=g(t,e),a.total=Math.round(o),o+=a.size),a}),i.source=i.add=this.value=u,i};var Me=t.fastmap({line:C,"line-radial":L,curve:q,"curve-radial":_,"orthogonal-horizontal":I,"orthogonal-vertical":N,"orthogonal-radial":P,"diagonal-horizontal":U,"diagonal-vertical":X,"diagonal-radial":Y}),xe=t.inherits(z,n.Transform);xe.transform=function(e,n){var r=e.sourceX||w,a=e.sourceY||D,i=e.targetX||F,o=e.targetY||R,u=e.as||"path",s=e.orient||"vertical",l=e.shape||"line",f=Me.get(l+"-"+s)||Me.get(l);return f||t.error("LinkPath unsupported type: "+e.shape+"-"+e.orient),n.visit(n.SOURCE,function(e){e[u]=f(r(e),a(e),i(e),o(e))}),n.reflow(e.modified()).modifies(u)};var Se=t.inherits(j,n.Transform);Se.transform=function(e,n){var r,a,o,u=e.as||["startAngle","endAngle"],s=u[0],l=u[1],f=e.field||t.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,v=c,g=(d-c)/i.sum(p),y=i.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),r=0;r<h;++r)o=p[y[r]],a=m[y[r]],a[s]=v,a[l]=v+=o*g;return this.value=p,n.reflow(e.modified()).modifies(u)};var ke=5,Oe=t.toSet([oe,te,re]),Ae=t.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","nice","zero","range","rangeStep","round","reverse","interpolate","interpolateGamma"]),be=t.inherits(G,n.Transform);be.transform=function(e,n){var r,i=n.dataflow,o=this.value;o&&!e.modified("type")||(this.value=o=a.scale((e.type||oe).toLowerCase())());for(r in e)Ae[r]||(t.isFunction(o[r])?o[r](e[r]):i.warn("Unsupported scale property: "+r));return V(o,e,H(o,e),i),n.fork(n.NO_SOURCE|n.NO_FIELDS)};var Ee="center",Te="normalize",we=t.inherits($,n.Transform);we.transform=function(e,n){var r,a,i,o,u,s,l,f,c,d,m,p,h,v=e.as||["y0","y1"],g=v[0],y=v[1],M=e.field||t.one,x=e.offset;for(r=ee(n.source,e.groupby,e.sort,M),i=0,u=r.length,l=r.max;i<u;++i)for(a=r[i],f=x===Ee?(l-a.sum)/2:0,c=x===Te?1/a.sum:1,p=f,h=0,o=0,s=a.length;o<s;++o)d=a[o],m=p,h+=M(d),p=c*h+f,d[g]=m,d[y]=p;return n.reflow(e.modified()).modifies(v)};var De={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","curve","diagonal","orthogonal"]},{name:"as",type:"string",default:"path"}]},Fe={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},Re={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:["y0","y1"]}]};n.register(De,z),n.register(Fe,j),n.register(Re,$),n.transform("AxisTicks",m),n.transform("DataJoin",p),n.transform("Encode",g),n.transform("LegendEntries",T),n.transform("Scale",G),e.transform=n.transform,e.definition=n.definition,e.scale=a.scale,e.scheme=a.scheme,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-util"),require("d3-format"),require("vega-scale"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-format","vega-scale","d3-array","d3-interpolate"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,t,r,a,i,o){"use strict";function u(e,n){return e.ticks?e.ticks(n):e.domain()}function s(e,n,t){var r=e.tickFormat?e.tickFormat(n,t):String;return e.type===ae?l(r,f(t)):r}function l(e,n){return function(t){return e(t)?n(t):""}}function f(e){var n=r.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return c(r.format(n),r.format(".1f")(1)[1])}return r.format(n)}function c(e,n){return function(t){var r,a,i=e(t),o=i.indexOf(n);if(o<0)return i;for(r=d(i,o),a=r<i.length?i.slice(r):"";--r>o;)if("0"!==i[r]){++r;break}return i.slice(0,r)+a}}function d(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if(t=e.charCodeAt(r),t>=48&&t<=57)return r+1}function m(e){n.Transform.call(this,[],e)}function p(e){n.Transform.call(this,null,e)}function h(){return n.ingest({})}function v(e){return e.exit}function g(e){n.Transform.call(this,null,e)}function y(e,n,t){if(t)return e.domain();var r=xe[e.type];return r?r(e):u(e,n)}function M(e){var n=e.domain(),r=n[0],a=t.peek(n),i=e.range().length,o=new Array(i),u=0;for(o[0]=r;++u<i;)o[u]=(u*a-(u-i)*r)/i;return o.max=a,o}function x(e){var n=e.domain(),r=[n[0]].concat(e.quantiles());return r.max=t.peek(n),r}function S(e){var n=[-(1/0)].concat(e.domain());return n.max=+(1/0),n}function b(e){var n=e.domain();return n.max=n.pop(),n}function k(e,n){return xe[e.type]?O(n):E(n)}function O(e){return function(n,t,r){var a=r[t+1]||r.max||+(1/0),i=A(n,e),o=A(a,e);return i&&o?i+"–"+o:o?"< "+o:"≥ "+i}}function A(e,n){return isFinite(e)?n(e):null}function E(e){return function(n){return e(n)}}function T(e){n.Transform.call(this,[],e)}function w(e){return e.source.x}function D(e){return e.source.y}function F(e){return e.target.x}function R(e){return e.target.y}function z(e){n.Transform.call(this,{},e)}function C(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function L(e,n,t,r){return C(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))}function q(e,n,t,r){var a=t-e,i=r-n,o=.2*(a+i),u=.2*(i-a);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function _(e,n,t,r){return q(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))}function I(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t}function N(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r}function P(e,n,t,r){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*a+","+n*i+"A"+n+","+n+" 0 0,"+(s?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u}function U(e,n,t,r){var a=(e+t)/2;return"M"+e+","+n+"C"+a+","+n+" "+a+","+r+" "+t+","+r}function X(e,n,t,r){var a=(n+r)/2;return"M"+e+","+n+"C"+e+","+a+" "+t+","+a+" "+t+","+r}function Y(e,n,t,r){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=(n+r)/2;return"M"+n*a+","+n*i+"C"+s*a+","+s*i+" "+s*o+","+s*u+" "+r*o+","+r*u}function j(e){n.Transform.call(this,null,e)}function G(e){n.Transform.call(this,null,e),this.modified(!0)}function H(e,n,t){var r=J(e,n.domainRaw);if(r>-1)return r;var a,i,o=n.domain,u=n.zero||void 0===n.zero&&Ee[e.type];return o?((u||null!=n.domainMin||null!=n.domainMax||null!=n.domainMid)&&(a=(o=o.slice()).length-1||1,u&&(o[0]>0&&(o[0]=0),o[a]<0&&(o[a]=0)),null!=n.domainMin&&(o[0]=n.domainMin),null!=n.domainMax&&(o[a]=n.domainMax),null!=n.domainMid&&(i=n.domainMid,(i<o[0]||i>o[a])&&t.warn("Scale domainMid exceeds domain min or max.",i),o.splice(a,0,i))),e.domain(o),n.nice&&e.nice&&e.nice(n.nice!==!0&&+n.nice||null),o.length):0}function J(e,n){return n?(e.domain(n),n.length):-1}function V(e,n,r){var i=n.round||!1,u=n.range;if(null!=n.rangeStep)u=B(e.type,n,r);else if(n.scheme){if(u=W(e.type,n,r),t.isFunction(u))return e.interpolator(u)}else if(u&&e.type===ve)return e.interpolator(o.interpolateRgbBasis(Q(u,n.reverse)));u&&n.interpolate&&e.interpolate?e.interpolate(a.interpolate(n.interpolate,n.interpolateGamma)):t.isFunction(e.round)?e.round(i):t.isFunction(e.rangeRound)&&e.interpolate(i?o.interpolateRound:o.interpolate),u&&e.range(Q(u,n.reverse))}function B(e,n,r){e!==ue&&e!==se&&t.error("Only band and point scales support rangeStep.");var i=(null!=n.paddingOuter?n.paddingOuter:n.padding)||0,o=e===se?1:(null!=n.paddingInner?n.paddingInner:n.padding)||0;return[0,n.rangeStep*a.bandSpace(r,o,i)]}function W(e,n,r){var i,o=n.scheme.toLowerCase(),u=a.scheme(o),s=n.schemeExtent;return u||t.error("Unrecognized scheme name: "+n.scheme),r=e===me?r+1:e===he?r-1:e===ce||e===de?+n.schemeCount||Ae:r,e===ve?K(u,s,n.reverse):!s&&(i=a.scheme(o+"-"+r))?i:t.isFunction(u)?Z(K(u,s),r):e===fe?u:u.slice(0,r)}function K(e,n,r){return t.isFunction(e)&&(n||r)?a.interpolateRange(e,Q(n||[0,1],r)):e}function Q(e,n){return n?e.slice().reverse():e}function Z(e,n){for(var t=new Array(n),r=n-1||1,a=0;a<n;++a)t[a]=e(a/r);return t}function $(e){n.Transform.call(this,null,e)}function ee(e,n,t,r,a){for(var i,o=(n-e.sum)/2,u=e.length,s=0;s<u;++s)i=e[s],i[r]=o,i[a]=o+=Math.abs(t(i))}function ne(e,n,t,r,a){for(var i,o=1/e.sum,u=0,s=e.length,l=0,f=0;l<s;++l)i=e[l],i[r]=u,i[a]=u=o*(f+=Math.abs(t(i)))}function te(e,n,t,r,a){for(var i,o,u=0,s=0,l=e.length,f=0;f<l;++f)o=e[f],i=t(o),i<0?(o[r]=s,o[a]=s+=i):(o[r]=u,o[a]=u+=i)}function re(e,n,t,r){var a,i,o,u,s,l,f,c,d,m=[],p=function(e){return e(s)};if(null==n)m.push(e.slice());else for(a={},i=0,o=e.length;i<o;++i)s=e[i],l=n.map(p),f=a[l]||(m.push(a[l]=[]),a[l]),f.push(s);for(l=0,d=0,u=m.length;l<u;++l){for(f=m[l],i=0,c=0,o=f.length;i<o;++i)c+=Math.abs(r(f[i]));f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}var ae="log",ie="pow",oe="sqrt",ue="band",se="point",le="linear",fe="ordinal",ce="quantile",de="quantize",me="threshold",pe="bin-linear",he="bin-ordinal",ve="sequential",ge=t.inherits(m,n.Transform);ge.transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var r=t.fork(t.NO_SOURCE|t.NO_FIELDS),a=this.value,i=e.scale,o=e.count,l=e.format||s(i,o,e.formatSpecifier),f=e.values||u(i,o);return a&&(r.rem=a),a=f.map(function(e){return n.ingest({value:e,label:l(e)})}),e.extra&&a.push(n.ingest({extra:{value:a[0].value},label:""})),r.source=r.add=this.value=a,r};var ye=t.inherits(p,n.Transform);ye.transform=function(e,r){var a=r.dataflow,i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=e.item||h,u=e.key||n.tupleid,s=this.value;return s||(r=r.addAll(),this.value=s=t.fastmap().test(v),s.lookup=function(e){return s.get(u(e))}),(e.modified("key")||r.modified(u))&&t.error("DataJoin does not support modified key function or fields."),r.visit(r.ADD,function(e){var n=u(e),t=s.get(n);t?(t.exit?(--s.empty,i.add):i.mod).push(t):(s.set(n,t=o(e)),i.add.push(t)),t.datum=e,t.exit=!1}),r.visit(r.MOD,function(e){var n=u(e),t=s.get(n);t&&(t.datum=e,i.mod.push(t))}),r.visit(r.REM,function(e){var n=u(e),t=s.get(n);e!==t.datum||t.exit||(i.rem.push(t),t.exit=!0,++s.empty)}),e.clean&&s.empty>a.cleanThreshold&&a.runAfter(s.clean),i};var Me=t.inherits(g,n.Transform);Me.transform=function(e,n){var r=n.fork(n.ADD_REM),a=n.encode,i="enter"===a,o=e.encoders.update||t.falsy,u=e.encoders.enter||t.falsy,s=e.encoders.exit||t.falsy,l=(a&&!i?e.encoders[a]:o)||t.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){u(n,e),o(n,e),l!==t.falsy&&l!==o&&l(n,e)}),r.modifies(u.output),r.modifies(o.output),l!==t.falsy&&l!==o&&r.modifies(l.output)),n.changed(n.REM)&&s!==t.falsy&&(n.visit(n.REM,function(n){s(n,e)}),r.modifies(s.output)),i||l!==t.falsy){var f=n.MOD|(e.modified()?n.REFLOW:0);i?(n.visit(f,function(n){var t=u(n,e);(l(n,e)||t)&&r.mod.push(n)}),r.mod.length&&r.modifies(u.output)):n.visit(f,function(n){l(n,e)&&r.mod.push(n)}),r.mod.length&&r.modifies(l.output)}return r};var xe={};xe[ce]=x,xe[de]=M,xe[me]=S,xe[pe]=b,xe[he]=b;var Se=t.inherits(T,n.Transform);Se.transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=0,u=this.value,l="gradient"===e.type,f=e.scale,c=null==e.count?5:e.count,d=e.format||s(f,c,e.formatSpecifier),m=e.values||y(f,c,l);if(d=k(f,d),u&&(i.rem=u),l)var p=e.values?f.domain():m,h=a.scaleFraction(f,p[0],t.peek(p));else{var v,g=e.size;t.isFunction(g)?(e.values||0!==f(m[0])||(m=m.slice(1)),v=m.reduce(function(n,t){return Math.max(n,g(t,e))},0)):g=t.constant(v=g||8)}return u=m.map(function(t,r){var a=n.ingest({index:r,label:d(t,r,m),value:t});return l?a.perc=h(t):(a.offset=v,a.size=g(t,e),a.total=Math.round(o),o+=a.size),a}),i.source=i.add=this.value=u,i};var be=t.fastmap({line:C,"line-radial":L,curve:q,"curve-radial":_,"orthogonal-horizontal":I,"orthogonal-vertical":N,"orthogonal-radial":P,"diagonal-horizontal":U,"diagonal-vertical":X,"diagonal-radial":Y}),ke=t.inherits(z,n.Transform);ke.transform=function(e,n){var r=e.sourceX||w,a=e.sourceY||D,i=e.targetX||F,o=e.targetY||R,u=e.as||"path",s=e.orient||"vertical",l=e.shape||"line",f=be.get(l+"-"+s)||be.get(l);return f||t.error("LinkPath unsupported type: "+e.shape+"-"+e.orient),n.visit(n.SOURCE,function(e){e[u]=f(r(e),a(e),i(e),o(e))}),n.reflow(e.modified()).modifies(u)};var Oe=t.inherits(j,n.Transform);Oe.transform=function(e,n){var r,a,o,u=e.as||["startAngle","endAngle"],s=u[0],l=u[1],f=e.field||t.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,v=c,g=(d-c)/i.sum(p),y=i.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),r=0;r<h;++r)o=p[y[r]],a=m[y[r]],a[s]=v,a[l]=v+=o*g;return this.value=p,n.reflow(e.modified()).modifies(u)};var Ae=5,Ee=t.toSet([le,ie,oe]),Te=t.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","nice","zero","range","rangeStep","round","reverse","interpolate","interpolateGamma"]),we=t.inherits(G,n.Transform);we.transform=function(e,n){var r,i=n.dataflow,o=this.value;o&&!e.modified("type")||(this.value=o=a.scale((e.type||le).toLowerCase())());for(r in e)Te[r]||(t.isFunction(o[r])?o[r](e[r]):i.warn("Unsupported scale property: "+r));return V(o,e,H(o,e),i),n.fork(n.NO_SOURCE|n.NO_FIELDS)};var De="center",Fe="normalize",Re=t.inherits($,n.Transform);Re.transform=function(e,n){var r,a,i,o,u=e.as||["y0","y1"],s=u[0],l=u[1],f=e.field||t.one,c=e.offset===De?ee:e.offset===Fe?ne:te;for(r=re(n.source,e.groupby,e.sort,f),a=0,i=r.length,o=r.max;a<i;++a)c(r[a],o,f,s,l);return n.reflow(e.modified()).modifies(u)};var ze={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","curve","diagonal","orthogonal"]},{name:"as",type:"string",default:"path"}]},Ce={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},Le={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:["y0","y1"]}]};n.register(ze,z),n.register(Ce,j),n.register(Le,$),n.transform("AxisTicks",m),n.transform("DataJoin",p),n.transform("Encode",g),n.transform("LegendEntries",T),n.transform("Scale",G),e.transform=n.transform,e.definition=n.definition,e.scale=a.scale,e.scheme=a.scheme,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "vega-encode",
"version": "1.0.0-beta.13",
"version": "1.0.0-beta.14",
"description": "Visual encoding transforms for Vega dataflows.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -27,5 +27,6 @@ import {Transform} from 'vega-dataflow';

field = _.field || one,
offset = _.offset,
groups, group, i, j, n, m,
max, off, scale, t, a, b, v;
stack = _.offset === Center ? stackCenter
: _.offset === Normalize ? stackNormalize
: stackZero,
groups, i, n, max;

@@ -37,15 +38,3 @@ // partition, sum, and sort the stack groups

for (i=0, n=groups.length, max=groups.max; i<n; ++i) {
group = groups[i];
off = offset === Center ? (max - group.sum)/2 : 0;
scale = offset === Normalize ? (1/group.sum) : 1;
// set stack coordinates for each datum in group
for (b=off, v=0, j=0, m=group.length; j<m; ++j) {
t = group[j];
a = b; // use previous value for start point
v += field(t);
b = scale * v + off; // compute end point
t[y0] = a;
t[y1] = b;
}
stack(groups[i], max, field, y0, y1);
}

@@ -56,2 +45,46 @@

function stackCenter(group, max, field, y0, y1) {
var last = (max - group.sum) / 2,
m = group.length,
j = 0, t;
for (; j<m; ++j) {
t = group[j];
t[y0] = last;
t[y1] = (last += Math.abs(field(t)));
}
}
function stackNormalize(group, max, field, y0, y1) {
var scale = 1 / group.sum,
last = 0,
m = group.length,
j = 0, v = 0, t;
for (; j<m; ++j) {
t = group[j];
t[y0] = last;
t[y1] = last = scale * (v += Math.abs(field(t)));
}
}
function stackZero(group, max, field, y0, y1) {
var lastPos = 0,
lastNeg = 0,
m = group.length,
j = 0, v, t;
for (; j<m; ++j) {
t = group[j];
v = field(t);
if (v < 0) {
t[y0] = lastNeg;
t[y1] = (lastNeg += v);
} else {
t[y0] = lastPos;
t[y1] = (lastPos += v);
}
}
}
function partition(data, groupby, sort, field) {

@@ -78,3 +111,3 @@ var groups = [],

for (i=0, s=0, n=g.length; i<n; ++i) {
s += field(g[i]);
s += Math.abs(field(g[i]));
}

@@ -81,0 +114,0 @@ g.sum = s;

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc