vega-encode
Advanced tools
Comparing version 4.8.1 to 4.8.2
@@ -193,3 +193,3 @@ (function (global, factory) { | ||
if (vegaUtil.isArray(encode)) { | ||
if (out.changed() || encode.every(function(e) { return encoders[e]; })) { | ||
if (out.changed() || encode.every(e => encoders[e])) { | ||
encode = encode[0]; | ||
@@ -210,7 +210,7 @@ out.encode = null; // consume targeted encode directive | ||
if (pulse.changed(pulse.ADD)) { | ||
pulse.visit(pulse.ADD, function(t) { enter(t, _); update(t, _); }); | ||
pulse.visit(pulse.ADD, t => { enter(t, _); update(t, _); }); | ||
out.modifies(enter.output); | ||
out.modifies(update.output); | ||
if (set !== vegaUtil.falsy && set !== update) { | ||
pulse.visit(pulse.ADD, function(t) { set(t, _); }); | ||
pulse.visit(pulse.ADD, t => { set(t, _); }); | ||
out.modifies(set.output); | ||
@@ -221,3 +221,3 @@ } | ||
if (pulse.changed(pulse.REM) && exit !== vegaUtil.falsy) { | ||
pulse.visit(pulse.REM, function(t) { exit(t, _); }); | ||
pulse.visit(pulse.REM, t => { exit(t, _); }); | ||
out.modifies(exit.output); | ||
@@ -229,3 +229,3 @@ } | ||
if (reenter) { | ||
pulse.visit(flag, function(t) { | ||
pulse.visit(flag, t => { | ||
var mod = enter(t, _) || fmod; | ||
@@ -236,3 +236,3 @@ if (set(t, _) || mod) out.mod.push(t); | ||
} else { | ||
pulse.visit(flag, function(t) { | ||
pulse.visit(flag, t => { | ||
if (set(t, _) || fmod) out.mod.push(t); | ||
@@ -305,5 +305,3 @@ }); | ||
// compute size offset for legend entries | ||
offset = items.reduce(function(max, value) { | ||
return Math.max(max, size(value, _)); | ||
}, 0); | ||
offset = items.reduce((max, value) => Math.max(max, size(value, _)), 0); | ||
} else { | ||
@@ -757,5 +755,3 @@ size = vegaUtil.constant(offset = size || 8); | ||
// if all pos or all neg, abs(sum) === domain.length | ||
var s = Math.abs(domain.reduce(function(s, v) { | ||
return s + (v < 0 ? -1 : v > 0 ? 1 : 0); | ||
}, 0)); | ||
var s = Math.abs(domain.reduce((s, v) => s + (v < 0 ? -1 : v > 0 ? 1 : 0), 0)); | ||
@@ -774,9 +770,10 @@ if (s !== domain.length) { | ||
// generate bin boundary array | ||
let domain = scale.domain(), | ||
lo = domain[0], | ||
hi = vegaUtil.peek(domain), | ||
start = bins.start == null ? lo : bins.start, | ||
stop = bins.stop == null ? hi : bins.stop, | ||
step = bins.step; | ||
const domain = scale.domain(), | ||
lo = domain[0], | ||
hi = vegaUtil.peek(domain), | ||
step = bins.step; | ||
let start = bins.start == null ? lo : bins.start, | ||
stop = bins.stop == null ? hi : bins.stop; | ||
if (!step) vegaUtil.error('Scale bins parameter missing step property.'); | ||
@@ -783,0 +780,0 @@ if (start < lo) start = step * Math.ceil(lo / step); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-scale"),require("vega-util"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scale","vega-util","d3-array","d3-interpolate"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3,e.d3)}(this,(function(e,n,t,a,i,r){"use strict";function o(e){n.Transform.call(this,null,e)}function l(e){n.Transform.call(this,null,e)}function s(){return n.ingest({})}function u(e){n.Transform.call(this,null,e)}function d(e){n.Transform.call(this,[],e)}a.inherits(o,n.Transform,{transform(e,a){if(this.value&&!e.modified())return a.StopPropagation;var i=a.dataflow.locale(),r=a.fork(a.NO_SOURCE|a.NO_FIELDS),o=this.value,l=e.scale,s=null==e.count?e.values?e.values.length:10:e.count,u=t.tickCount(l,s,e.minstep),d=e.format||t.tickFormat(i,l,u,e.formatSpecifier,e.formatType,!!e.values),m=e.values?t.validTicks(l,e.values,u):t.tickValues(l,u);return o&&(r.rem=o),o=m.map((e,t)=>n.ingest({index:t/(m.length-1||1),value:e,label:d(e)})),e.extra&&o.length&&o.push(n.ingest({index:-1,extra:{value:o[0].value},label:""})),r.source=o,r.add=o,this.value=o,r}}),a.inherits(l,n.Transform,{transform(e,t){var i=t.dataflow,r=t.fork(t.NO_SOURCE|t.NO_FIELDS),o=e.item||s,l=e.key||n.tupleid,u=this.value;return a.isArray(r.encode)&&(r.encode=null),u&&(e.modified("key")||t.modified(l))&&a.error("DataJoin does not support modified key function or fields."),u||(t=t.addAll(),this.value=u=function(e){const n=a.fastmap().test(e=>e.exit);return n.lookup=t=>n.get(e(t)),n}(l)),t.visit(t.ADD,e=>{const n=l(e);let t=u.get(n);t?t.exit?(u.empty--,r.add.push(t)):r.mod.push(t):(t=o(e),u.set(n,t),r.add.push(t)),t.datum=e,t.exit=!1}),t.visit(t.MOD,e=>{const n=l(e),t=u.get(n);t&&(t.datum=e,r.mod.push(t))}),t.visit(t.REM,e=>{const n=l(e),t=u.get(n);e!==t.datum||t.exit||(r.rem.push(t),t.exit=!0,++u.empty)}),t.changed(t.ADD_MOD)&&r.modifies("datum"),(t.clean()||e.clean&&u.empty>i.cleanThreshold)&&i.runAfter(u.clean),r}}),a.inherits(u,n.Transform,{transform(e,n){var t=n.fork(n.ADD_REM),i=e.mod||!1,r=e.encoders,o=n.encode;if(a.isArray(o)){if(!t.changed()&&!o.every((function(e){return r[e]})))return n.StopPropagation;o=o[0],t.encode=null}var l="enter"===o,s=r.update||a.falsy,u=r.enter||a.falsy,d=r.exit||a.falsy,m=(o&&!l?r[o]:s)||a.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,(function(n){u(n,e),s(n,e)})),t.modifies(u.output),t.modifies(s.output),m!==a.falsy&&m!==s&&(n.visit(n.ADD,(function(n){m(n,e)})),t.modifies(m.output))),n.changed(n.REM)&&d!==a.falsy&&(n.visit(n.REM,(function(n){d(n,e)})),t.modifies(d.output)),l||m!==a.falsy){var c=n.MOD|(e.modified()?n.REFLOW:0);l?(n.visit(c,(function(n){var a=u(n,e)||i;(m(n,e)||a)&&t.mod.push(n)})),t.mod.length&&t.modifies(u.output)):n.visit(c,(function(n){(m(n,e)||i)&&t.mod.push(n)})),t.mod.length&&t.modifies(m.output)}return t.changed()?t:n.StopPropagation}}),a.inherits(d,n.Transform,{transform(e,i){if(null!=this.value&&!e.modified())return i.StopPropagation;var r,o,l,s,u,d=i.dataflow.locale(),m=i.fork(i.NO_SOURCE|i.NO_FIELDS),c=this.value,f=e.type||t.SymbolLegend,p=e.scale,h=+e.limit,g=t.tickCount(p,null==e.count?5:e.count,e.minstep),v=!!e.values||f===t.SymbolLegend,y=e.format||t.labelFormat(d,p,g,f,e.formatSpecifier,e.formatType,v),M=e.values||t.labelValues(p,g);return c&&(m.rem=c),f===t.SymbolLegend?(h&&M.length>h?(i.dataflow.warn("Symbol legend count exceeds limit, filtering items."),c=M.slice(0,h-1),u=!0):c=M,a.isFunction(l=e.size)?(e.values||0!==p(c[0])||(c=c.slice(1)),s=c.reduce((function(n,t){return Math.max(n,l(t,e))}),0)):l=a.constant(s=l||8),c=c.map((t,a)=>n.ingest({index:a,label:y(t,a,c),value:t,offset:s,size:l(t,e)})),u&&(u=M[c.length],c.push(n.ingest({index:c.length,label:`…${M.length-c.length} entries`,value:u,offset:s,size:l(u,e)})))):f===t.GradientLegend?(r=p.domain(),o=t.scaleFraction(p,r[0],a.peek(r)),M.length<3&&!e.values&&r[0]!==a.peek(r)&&(M=[r[0],a.peek(r)]),c=M.map((e,t)=>n.ingest({index:t,label:y(e,t,M),value:e,perc:o(e)}))):(l=M.length-1,o=t.labelFraction(p),c=M.map((e,t)=>n.ingest({index:t,label:y(e,t,M),value:e,perc:t?o(e):0,perc2:t===l?1:o(M[t+1])}))),m.source=c,m.add=c,this.value=c,m}});const m=e=>e.source.x,c=e=>e.source.y,f=e=>e.target.x,p=e=>e.target.y;function h(e){n.Transform.call(this,{},e)}h.Definition={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","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]},a.inherits(h,n.Transform,{transform(e,n){var t=e.sourceX||m,i=e.sourceY||c,r=e.targetX||f,o=e.targetY||p,l=e.as||"path",s=e.orient||"vertical",u=e.shape||"line",d=M.get(u+"-"+s)||M.get(u);return d||a.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),n.visit(n.SOURCE,e=>{e[l]=d(t(e),i(e),r(e),o(e))}),n.reflow(e.modified()).modifies(l)}});const g=(e,n,t,a)=>"M"+e+","+n+"L"+t+","+a,v=(e,n,t,a)=>{var i=t-e,r=a-n,o=Math.sqrt(i*i+r*r)/2;return"M"+e+","+n+"A"+o+","+o+" "+180*Math.atan2(r,i)/Math.PI+" 0 1 "+t+","+a},y=(e,n,t,a)=>{const i=t-e,r=a-n,o=.2*(i+r),l=.2*(r-i);return"M"+e+","+n+"C"+(e+o)+","+(n+l)+" "+(t+l)+","+(a-o)+" "+t+","+a},M=a.fastmap({line:g,"line-radial":(e,n,t,a)=>g(n*Math.cos(e),n*Math.sin(e),a*Math.cos(t),a*Math.sin(t)),arc:v,"arc-radial":(e,n,t,a)=>v(n*Math.cos(e),n*Math.sin(e),a*Math.cos(t),a*Math.sin(t)),curve:y,"curve-radial":(e,n,t,a)=>y(n*Math.cos(e),n*Math.sin(e),a*Math.cos(t),a*Math.sin(t)),"orthogonal-horizontal":(e,n,t,a)=>"M"+e+","+n+"V"+a+"H"+t,"orthogonal-vertical":(e,n,t,a)=>"M"+e+","+n+"H"+t+"V"+a,"orthogonal-radial":(e,n,t,a)=>{const i=Math.cos(e),r=Math.sin(e),o=Math.cos(t),l=Math.sin(t);return"M"+n*i+","+n*r+"A"+n+","+n+" 0 0,"+((Math.abs(t-e)>Math.PI?t<=e:t>e)?1:0)+" "+n*o+","+n*l+"L"+a*o+","+a*l},"diagonal-horizontal":(e,n,t,a)=>{const i=(e+t)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+a+" "+t+","+a},"diagonal-vertical":(e,n,t,a)=>{const i=(n+a)/2;return"M"+e+","+n+"C"+e+","+i+" "+t+","+i+" "+t+","+a},"diagonal-radial":(e,n,t,a)=>{const i=Math.cos(e),r=Math.sin(e),o=Math.cos(t),l=Math.sin(t),s=(n+a)/2;return"M"+n*i+","+n*r+"C"+s*i+","+s*r+" "+s*o+","+s*l+" "+a*o+","+a*l}});function b(e){n.Transform.call(this,null,e)}b.Definition={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"]}]},a.inherits(b,n.Transform,{transform(e,n){var t,r,o,l=e.as||["startAngle","endAngle"],s=l[0],u=l[1],d=e.field||a.one,m=e.startAngle||0,c=null!=e.endAngle?e.endAngle:2*Math.PI,f=n.source,p=f.map(d),h=p.length,g=m,v=(c-m)/i.sum(p),y=i.range(h);for(e.sort&&y.sort((e,n)=>p[e]-p[n]),t=0;t<h;++t)o=p[y[t]],(r=f[y[t]])[s]=g,r[u]=g+=o*v;return this.value=p,n.reflow(e.modified()).modifies(l)}});function S(e){return t.isContinuous(e)&&e!==t.Sequential}const x=a.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function k(e){n.Transform.call(this,null,e),this.modified(!0)}function D(e,n,i){t.isLogarithmic(e)&&(Math.abs(n.reduce((function(e,n){return e+(n<0?-1:n>0?1:0)}),0))!==n.length&&i.warn("Log scale domain includes zero: "+a.stringValue(n)));return n}function T(e,n,i){return a.isFunction(e)&&(n||i)?t.interpolateRange(e,w(n||[0,1],i)):e}function w(e,n){return n?e.slice().reverse():e}function O(e){n.Transform.call(this,null,e)}a.inherits(k,n.Transform,{transform(e,n){var o=n.dataflow,l=this.value,s=function(e){var n,i=e.type,r="";if(i===t.Sequential)return t.Sequential+"-"+t.Linear;(function(e){const n=e.type;return t.isContinuous(n)&&n!==t.Time&&n!==t.UTC&&(e.scheme||e.range&&e.range.length&&e.range.every(a.isString))})(e)&&(r=2===(n=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0)?t.Sequential+"-":3===n?t.Diverging+"-":"");return(r+i||t.Linear).toLowerCase()}(e);for(s in l&&s===l.type||(this.value=l=t.scale(s)()),e)if(!x[s]){if("padding"===s&&S(l.type))continue;a.isFunction(l[s])?l[s](e[s]):o.warn("Unsupported scale property: "+s)}return function(e,n,i){var o=e.type,l=n.round||!1,s=n.range;if(null!=n.rangeStep)s=function(e,n,i){e!==t.Band&&e!==t.Point&&a.error("Only band and point scales support rangeStep.");var r=(null!=n.paddingOuter?n.paddingOuter:n.padding)||0,o=e===t.Point?1:(null!=n.paddingInner?n.paddingInner:n.padding)||0;return[0,n.rangeStep*t.bandSpace(i,o,r)]}(o,n,i);else if(n.scheme&&(s=function(e,n,i){var r,o,l=n.schemeExtent;a.isArray(n.scheme)?o=t.interpolateColors(n.scheme,n.interpolate,n.interpolateGamma):(r=n.scheme.toLowerCase(),(o=t.scheme(r))||a.error("Unrecognized scheme name: "+n.scheme));return i=e===t.Threshold?i+1:e===t.BinOrdinal?i-1:e===t.Quantile||e===t.Quantize?+n.schemeCount||5:i,t.isInterpolating(e)?T(o,l,n.reverse):a.isFunction(o)?t.quantizeInterpolator(T(o,l),i):e===t.Ordinal?o:o.slice(0,i)}(o,n,i),a.isFunction(s))){if(e.interpolator)return e.interpolator(s);a.error(`Scale type ${o} does not support interpolating color schemes.`)}if(s&&t.isInterpolating(o))return e.interpolator(t.interpolateColors(w(s,n.reverse),n.interpolate,n.interpolateGamma));s&&n.interpolate&&e.interpolate?e.interpolate(t.interpolate(n.interpolate,n.interpolateGamma)):a.isFunction(e.round)?e.round(l):a.isFunction(e.rangeRound)&&e.interpolate(l?r.interpolateRound:r.interpolate);s&&e.range(w(s,n.reverse))}(l,e,function(e,n,r){let o=n.bins;if(o&&!a.isArray(o)){let n=e.domain(),t=n[0],r=a.peek(n),l=null==o.start?t:o.start,s=null==o.stop?r:o.stop,u=o.step;u||a.error("Scale bins parameter missing step property."),l<t&&(l=u*Math.ceil(t/u)),s>r&&(s=u*Math.floor(r/u)),o=i.range(l,s+u/2,u)}o?e.bins=o:e.bins&&delete e.bins;e.type===t.BinOrdinal&&(o?n.domain||n.domainRaw||(e.domain(o),r=o.length):e.bins=e.domain());return r}(l,e,function(e,n,i){var r=function(e,n,t){return n?(e.domain(D(e.type,n,t)),n.length):-1}(e,n.domainRaw,i);if(r>-1)return r;var o,l,s=n.domain,u=e.type,d=n.zero||void 0===n.zero&&function(e){const n=e.type;return!e.bins&&(n===t.Linear||n===t.Pow||n===t.Sqrt)}(e);if(!s)return 0;S(u)&&n.padding&&s[0]!==a.peek(s)&&(s=function(e,n,i,r,o,l){var s=Math.abs(a.peek(i)-i[0]),u=s/(s-2*r),d=e===t.Log?a.zoomLog(n,null,u):e===t.Sqrt?a.zoomPow(n,null,u,.5):e===t.Pow?a.zoomPow(n,null,u,o||1):e===t.Symlog?a.zoomSymlog(n,null,u,l||1):a.zoomLinear(n,null,u);return(n=n.slice())[0]=d[0],n[n.length-1]=d[1],n}(u,s,n.range,n.padding,n.exponent,n.constant));if((d||null!=n.domainMin||null!=n.domainMax||null!=n.domainMid)&&(o=(s=s.slice()).length-1||1,d&&(s[0]>0&&(s[0]=0),s[o]<0&&(s[o]=0)),null!=n.domainMin&&(s[0]=n.domainMin),null!=n.domainMax&&(s[o]=n.domainMax),null!=n.domainMid)){const e=(l=n.domainMid)>s[o]?o+1:l<s[0]?0:o;e!==o&&i.warn("Scale domainMid exceeds domain min or max.",l),s.splice(e,0,l)}e.domain(D(u,s,i)),u===t.Ordinal&&e.unknown(n.domainImplicit?t.scaleImplicit:void 0);n.nice&&e.nice&&e.nice(!0!==n.nice&&t.tickCount(e,n.nice)||null);return s.length}(l,e,o))),n.fork(n.NO_SOURCE|n.NO_FIELDS)}}),a.inherits(O,n.Transform,{transform(e,t){const a=e.modified("sort")||t.changed(t.ADD)||t.modified(e.sort.fields)||t.modified("datum");return a&&t.source.sort(n.stableCompare(e.sort)),this.modified(a),t}});const A=["y0","y1"];function C(e){n.Transform.call(this,null,e)}function L(e,n,t,a,i){for(var r,o=(n-e.sum)/2,l=e.length,s=0;s<l;++s)(r=e[s])[a]=o,r[i]=o+=Math.abs(t(r))}function z(e,n,t,a,i){for(var r,o=1/e.sum,l=0,s=e.length,u=0,d=0;u<s;++u)(r=e[u])[a]=l,r[i]=l=o*(d+=Math.abs(t(r)))}function P(e,n,t,a,i){for(var r,o,l=0,s=0,u=e.length,d=0;d<u;++d)(r=+t(o=e[d]))<0?(o[a]=s,o[i]=s+=r):(o[a]=l,o[i]=l+=r)}C.Definition={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:A}]},a.inherits(C,n.Transform,{transform(e,t){var i,r,o,l,s=e.as||A,u=s[0],d=s[1],m=n.stableCompare(e.sort),c=e.field||a.one,f="center"===e.offset?L:"normalize"===e.offset?z:P;for(i=function(e,n,t,a){var i,r,o,l,s,u,d,m,c,f=[],p=e=>e(s);if(null==n)f.push(e.slice());else for(i={},r=0,o=e.length;r<o;++r)s=e[r],(d=i[u=n.map(p)])||(i[u]=d=[],f.push(d)),d.push(s);for(u=0,c=0,l=f.length;u<l;++u){for(r=0,m=0,o=(d=f[u]).length;r<o;++r)m+=Math.abs(a(d[r]));d.sum=m,m>c&&(c=m),t&&d.sort(t)}return f.max=c,f}(t.source,e.groupby,m,c),r=0,o=i.length,l=i.max;r<o;++r)f(i[r],l,c,u,d);return t.reflow(e.modified()).modifies(s)}}),e.axisticks=o,e.datajoin=l,e.encode=u,e.legendentries=d,e.linkpath=h,e.pie=b,e.scale=k,e.sortitems=O,e.stack=C,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-scale"),require("vega-util"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scale","vega-util","d3-array","d3-interpolate"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3,e.d3)}(this,(function(e,t,n,a,i,r){"use strict";function o(e){t.Transform.call(this,null,e)}function l(e){t.Transform.call(this,null,e)}function s(){return t.ingest({})}function u(e){t.Transform.call(this,null,e)}function d(e){t.Transform.call(this,[],e)}a.inherits(o,t.Transform,{transform(e,a){if(this.value&&!e.modified())return a.StopPropagation;var i=a.dataflow.locale(),r=a.fork(a.NO_SOURCE|a.NO_FIELDS),o=this.value,l=e.scale,s=null==e.count?e.values?e.values.length:10:e.count,u=n.tickCount(l,s,e.minstep),d=e.format||n.tickFormat(i,l,u,e.formatSpecifier,e.formatType,!!e.values),m=e.values?n.validTicks(l,e.values,u):n.tickValues(l,u);return o&&(r.rem=o),o=m.map((e,n)=>t.ingest({index:n/(m.length-1||1),value:e,label:d(e)})),e.extra&&o.length&&o.push(t.ingest({index:-1,extra:{value:o[0].value},label:""})),r.source=o,r.add=o,this.value=o,r}}),a.inherits(l,t.Transform,{transform(e,n){var i=n.dataflow,r=n.fork(n.NO_SOURCE|n.NO_FIELDS),o=e.item||s,l=e.key||t.tupleid,u=this.value;return a.isArray(r.encode)&&(r.encode=null),u&&(e.modified("key")||n.modified(l))&&a.error("DataJoin does not support modified key function or fields."),u||(n=n.addAll(),this.value=u=function(e){const t=a.fastmap().test(e=>e.exit);return t.lookup=n=>t.get(e(n)),t}(l)),n.visit(n.ADD,e=>{const t=l(e);let n=u.get(t);n?n.exit?(u.empty--,r.add.push(n)):r.mod.push(n):(n=o(e),u.set(t,n),r.add.push(n)),n.datum=e,n.exit=!1}),n.visit(n.MOD,e=>{const t=l(e),n=u.get(t);n&&(n.datum=e,r.mod.push(n))}),n.visit(n.REM,e=>{const t=l(e),n=u.get(t);e!==n.datum||n.exit||(r.rem.push(n),n.exit=!0,++u.empty)}),n.changed(n.ADD_MOD)&&r.modifies("datum"),(n.clean()||e.clean&&u.empty>i.cleanThreshold)&&i.runAfter(u.clean),r}}),a.inherits(u,t.Transform,{transform(e,t){var n=t.fork(t.ADD_REM),i=e.mod||!1,r=e.encoders,o=t.encode;if(a.isArray(o)){if(!n.changed()&&!o.every(e=>r[e]))return t.StopPropagation;o=o[0],n.encode=null}var l="enter"===o,s=r.update||a.falsy,u=r.enter||a.falsy,d=r.exit||a.falsy,m=(o&&!l?r[o]:s)||a.falsy;if(t.changed(t.ADD)&&(t.visit(t.ADD,t=>{u(t,e),s(t,e)}),n.modifies(u.output),n.modifies(s.output),m!==a.falsy&&m!==s&&(t.visit(t.ADD,t=>{m(t,e)}),n.modifies(m.output))),t.changed(t.REM)&&d!==a.falsy&&(t.visit(t.REM,t=>{d(t,e)}),n.modifies(d.output)),l||m!==a.falsy){var c=t.MOD|(e.modified()?t.REFLOW:0);l?(t.visit(c,t=>{var a=u(t,e)||i;(m(t,e)||a)&&n.mod.push(t)}),n.mod.length&&n.modifies(u.output)):t.visit(c,t=>{(m(t,e)||i)&&n.mod.push(t)}),n.mod.length&&n.modifies(m.output)}return n.changed()?n:t.StopPropagation}}),a.inherits(d,t.Transform,{transform(e,i){if(null!=this.value&&!e.modified())return i.StopPropagation;var r,o,l,s,u,d=i.dataflow.locale(),m=i.fork(i.NO_SOURCE|i.NO_FIELDS),c=this.value,f=e.type||n.SymbolLegend,p=e.scale,h=+e.limit,g=n.tickCount(p,null==e.count?5:e.count,e.minstep),v=!!e.values||f===n.SymbolLegend,y=e.format||n.labelFormat(d,p,g,f,e.formatSpecifier,e.formatType,v),M=e.values||n.labelValues(p,g);return c&&(m.rem=c),f===n.SymbolLegend?(h&&M.length>h?(i.dataflow.warn("Symbol legend count exceeds limit, filtering items."),c=M.slice(0,h-1),u=!0):c=M,a.isFunction(l=e.size)?(e.values||0!==p(c[0])||(c=c.slice(1)),s=c.reduce((t,n)=>Math.max(t,l(n,e)),0)):l=a.constant(s=l||8),c=c.map((n,a)=>t.ingest({index:a,label:y(n,a,c),value:n,offset:s,size:l(n,e)})),u&&(u=M[c.length],c.push(t.ingest({index:c.length,label:`…${M.length-c.length} entries`,value:u,offset:s,size:l(u,e)})))):f===n.GradientLegend?(r=p.domain(),o=n.scaleFraction(p,r[0],a.peek(r)),M.length<3&&!e.values&&r[0]!==a.peek(r)&&(M=[r[0],a.peek(r)]),c=M.map((e,n)=>t.ingest({index:n,label:y(e,n,M),value:e,perc:o(e)}))):(l=M.length-1,o=n.labelFraction(p),c=M.map((e,n)=>t.ingest({index:n,label:y(e,n,M),value:e,perc:n?o(e):0,perc2:n===l?1:o(M[n+1])}))),m.source=c,m.add=c,this.value=c,m}});const m=e=>e.source.x,c=e=>e.source.y,f=e=>e.target.x,p=e=>e.target.y;function h(e){t.Transform.call(this,{},e)}h.Definition={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","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]},a.inherits(h,t.Transform,{transform(e,t){var n=e.sourceX||m,i=e.sourceY||c,r=e.targetX||f,o=e.targetY||p,l=e.as||"path",s=e.orient||"vertical",u=e.shape||"line",d=M.get(u+"-"+s)||M.get(u);return d||a.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),t.visit(t.SOURCE,e=>{e[l]=d(n(e),i(e),r(e),o(e))}),t.reflow(e.modified()).modifies(l)}});const g=(e,t,n,a)=>"M"+e+","+t+"L"+n+","+a,v=(e,t,n,a)=>{var i=n-e,r=a-t,o=Math.sqrt(i*i+r*r)/2;return"M"+e+","+t+"A"+o+","+o+" "+180*Math.atan2(r,i)/Math.PI+" 0 1 "+n+","+a},y=(e,t,n,a)=>{const i=n-e,r=a-t,o=.2*(i+r),l=.2*(r-i);return"M"+e+","+t+"C"+(e+o)+","+(t+l)+" "+(n+l)+","+(a-o)+" "+n+","+a},M=a.fastmap({line:g,"line-radial":(e,t,n,a)=>g(t*Math.cos(e),t*Math.sin(e),a*Math.cos(n),a*Math.sin(n)),arc:v,"arc-radial":(e,t,n,a)=>v(t*Math.cos(e),t*Math.sin(e),a*Math.cos(n),a*Math.sin(n)),curve:y,"curve-radial":(e,t,n,a)=>y(t*Math.cos(e),t*Math.sin(e),a*Math.cos(n),a*Math.sin(n)),"orthogonal-horizontal":(e,t,n,a)=>"M"+e+","+t+"V"+a+"H"+n,"orthogonal-vertical":(e,t,n,a)=>"M"+e+","+t+"H"+n+"V"+a,"orthogonal-radial":(e,t,n,a)=>{const i=Math.cos(e),r=Math.sin(e),o=Math.cos(n),l=Math.sin(n);return"M"+t*i+","+t*r+"A"+t+","+t+" 0 0,"+((Math.abs(n-e)>Math.PI?n<=e:n>e)?1:0)+" "+t*o+","+t*l+"L"+a*o+","+a*l},"diagonal-horizontal":(e,t,n,a)=>{const i=(e+n)/2;return"M"+e+","+t+"C"+i+","+t+" "+i+","+a+" "+n+","+a},"diagonal-vertical":(e,t,n,a)=>{const i=(t+a)/2;return"M"+e+","+t+"C"+e+","+i+" "+n+","+i+" "+n+","+a},"diagonal-radial":(e,t,n,a)=>{const i=Math.cos(e),r=Math.sin(e),o=Math.cos(n),l=Math.sin(n),s=(t+a)/2;return"M"+t*i+","+t*r+"C"+s*i+","+s*r+" "+s*o+","+s*l+" "+a*o+","+a*l}});function b(e){t.Transform.call(this,null,e)}b.Definition={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"]}]},a.inherits(b,t.Transform,{transform(e,t){var n,r,o,l=e.as||["startAngle","endAngle"],s=l[0],u=l[1],d=e.field||a.one,m=e.startAngle||0,c=null!=e.endAngle?e.endAngle:2*Math.PI,f=t.source,p=f.map(d),h=p.length,g=m,v=(c-m)/i.sum(p),y=i.range(h);for(e.sort&&y.sort((e,t)=>p[e]-p[t]),n=0;n<h;++n)o=p[y[n]],(r=f[y[n]])[s]=g,r[u]=g+=o*v;return this.value=p,t.reflow(e.modified()).modifies(l)}});function S(e){return n.isContinuous(e)&&e!==n.Sequential}const x=a.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function k(e){t.Transform.call(this,null,e),this.modified(!0)}function D(e,t,i){n.isLogarithmic(e)&&(Math.abs(t.reduce((e,t)=>e+(t<0?-1:t>0?1:0),0))!==t.length&&i.warn("Log scale domain includes zero: "+a.stringValue(t)));return t}function T(e,t,i){return a.isFunction(e)&&(t||i)?n.interpolateRange(e,w(t||[0,1],i)):e}function w(e,t){return t?e.slice().reverse():e}function O(e){t.Transform.call(this,null,e)}a.inherits(k,t.Transform,{transform(e,t){var o=t.dataflow,l=this.value,s=function(e){var t,i=e.type,r="";if(i===n.Sequential)return n.Sequential+"-"+n.Linear;(function(e){const t=e.type;return n.isContinuous(t)&&t!==n.Time&&t!==n.UTC&&(e.scheme||e.range&&e.range.length&&e.range.every(a.isString))})(e)&&(r=2===(t=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0)?n.Sequential+"-":3===t?n.Diverging+"-":"");return(r+i||n.Linear).toLowerCase()}(e);for(s in l&&s===l.type||(this.value=l=n.scale(s)()),e)if(!x[s]){if("padding"===s&&S(l.type))continue;a.isFunction(l[s])?l[s](e[s]):o.warn("Unsupported scale property: "+s)}return function(e,t,i){var o=e.type,l=t.round||!1,s=t.range;if(null!=t.rangeStep)s=function(e,t,i){e!==n.Band&&e!==n.Point&&a.error("Only band and point scales support rangeStep.");var r=(null!=t.paddingOuter?t.paddingOuter:t.padding)||0,o=e===n.Point?1:(null!=t.paddingInner?t.paddingInner:t.padding)||0;return[0,t.rangeStep*n.bandSpace(i,o,r)]}(o,t,i);else if(t.scheme&&(s=function(e,t,i){var r,o,l=t.schemeExtent;a.isArray(t.scheme)?o=n.interpolateColors(t.scheme,t.interpolate,t.interpolateGamma):(r=t.scheme.toLowerCase(),(o=n.scheme(r))||a.error("Unrecognized scheme name: "+t.scheme));return i=e===n.Threshold?i+1:e===n.BinOrdinal?i-1:e===n.Quantile||e===n.Quantize?+t.schemeCount||5:i,n.isInterpolating(e)?T(o,l,t.reverse):a.isFunction(o)?n.quantizeInterpolator(T(o,l),i):e===n.Ordinal?o:o.slice(0,i)}(o,t,i),a.isFunction(s))){if(e.interpolator)return e.interpolator(s);a.error(`Scale type ${o} does not support interpolating color schemes.`)}if(s&&n.isInterpolating(o))return e.interpolator(n.interpolateColors(w(s,t.reverse),t.interpolate,t.interpolateGamma));s&&t.interpolate&&e.interpolate?e.interpolate(n.interpolate(t.interpolate,t.interpolateGamma)):a.isFunction(e.round)?e.round(l):a.isFunction(e.rangeRound)&&e.interpolate(l?r.interpolateRound:r.interpolate);s&&e.range(w(s,t.reverse))}(l,e,function(e,t,r){let o=t.bins;if(o&&!a.isArray(o)){const t=e.domain(),n=t[0],r=a.peek(t),l=o.step;let s=null==o.start?n:o.start,u=null==o.stop?r:o.stop;l||a.error("Scale bins parameter missing step property."),s<n&&(s=l*Math.ceil(n/l)),u>r&&(u=l*Math.floor(r/l)),o=i.range(s,u+l/2,l)}o?e.bins=o:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(o?t.domain||t.domainRaw||(e.domain(o),r=o.length):e.bins=e.domain());return r}(l,e,function(e,t,i){var r=function(e,t,n){return t?(e.domain(D(e.type,t,n)),t.length):-1}(e,t.domainRaw,i);if(r>-1)return r;var o,l,s=t.domain,u=e.type,d=t.zero||void 0===t.zero&&function(e){const t=e.type;return!e.bins&&(t===n.Linear||t===n.Pow||t===n.Sqrt)}(e);if(!s)return 0;S(u)&&t.padding&&s[0]!==a.peek(s)&&(s=function(e,t,i,r,o,l){var s=Math.abs(a.peek(i)-i[0]),u=s/(s-2*r),d=e===n.Log?a.zoomLog(t,null,u):e===n.Sqrt?a.zoomPow(t,null,u,.5):e===n.Pow?a.zoomPow(t,null,u,o||1):e===n.Symlog?a.zoomSymlog(t,null,u,l||1):a.zoomLinear(t,null,u);return(t=t.slice())[0]=d[0],t[t.length-1]=d[1],t}(u,s,t.range,t.padding,t.exponent,t.constant));if((d||null!=t.domainMin||null!=t.domainMax||null!=t.domainMid)&&(o=(s=s.slice()).length-1||1,d&&(s[0]>0&&(s[0]=0),s[o]<0&&(s[o]=0)),null!=t.domainMin&&(s[0]=t.domainMin),null!=t.domainMax&&(s[o]=t.domainMax),null!=t.domainMid)){const e=(l=t.domainMid)>s[o]?o+1:l<s[0]?0:o;e!==o&&i.warn("Scale domainMid exceeds domain min or max.",l),s.splice(e,0,l)}e.domain(D(u,s,i)),u===n.Ordinal&&e.unknown(t.domainImplicit?n.scaleImplicit:void 0);t.nice&&e.nice&&e.nice(!0!==t.nice&&n.tickCount(e,t.nice)||null);return s.length}(l,e,o))),t.fork(t.NO_SOURCE|t.NO_FIELDS)}}),a.inherits(O,t.Transform,{transform(e,n){const a=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return a&&n.source.sort(t.stableCompare(e.sort)),this.modified(a),n}});const A="zero",C="center",L="normalize",z=["y0","y1"];function P(e){t.Transform.call(this,null,e)}function E(e,t,n,a,i){for(var r,o=(t-e.sum)/2,l=e.length,s=0;s<l;++s)(r=e[s])[a]=o,r[i]=o+=Math.abs(n(r))}function F(e,t,n,a,i){for(var r,o=1/e.sum,l=0,s=e.length,u=0,d=0;u<s;++u)(r=e[u])[a]=l,r[i]=l=o*(d+=Math.abs(n(r)))}function R(e,t,n,a,i){for(var r,o,l=0,s=0,u=e.length,d=0;d<u;++d)(r=+n(o=e[d]))<0?(o[a]=s,o[i]=s+=r):(o[a]=l,o[i]=l+=r)}P.Definition={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:A,values:[A,C,L]},{name:"as",type:"string",array:!0,length:2,default:z}]},a.inherits(P,t.Transform,{transform(e,n){var i,r,o,l,s=e.as||z,u=s[0],d=s[1],m=t.stableCompare(e.sort),c=e.field||a.one,f=e.offset===C?E:e.offset===L?F:R;for(i=function(e,t,n,a){var i,r,o,l,s,u,d,m,c,f=[],p=e=>e(s);if(null==t)f.push(e.slice());else for(i={},r=0,o=e.length;r<o;++r)s=e[r],(d=i[u=t.map(p)])||(i[u]=d=[],f.push(d)),d.push(s);for(u=0,c=0,l=f.length;u<l;++u){for(r=0,m=0,o=(d=f[u]).length;r<o;++r)m+=Math.abs(a(d[r]));d.sum=m,m>c&&(c=m),n&&d.sort(n)}return f.max=c,f}(n.source,e.groupby,m,c),r=0,o=i.length,l=i.max;r<o;++r)f(i[r],l,c,u,d);return n.reflow(e.modified()).modifies(s)}}),e.axisticks=o,e.datajoin=l,e.encode=u,e.legendentries=d,e.linkpath=h,e.pie=b,e.scale=k,e.sortitems=O,e.stack=P,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "vega-encode", | ||
"version": "4.8.1", | ||
"version": "4.8.2", | ||
"description": "Visual encoding transforms for Vega dataflows.", | ||
@@ -27,7 +27,7 @@ "keywords": [ | ||
"dependencies": { | ||
"d3-array": "^2.5.1", | ||
"d3-interpolate": "^1.4.0", | ||
"vega-dataflow": "^5.7.1", | ||
"vega-scale": "^7.0.1", | ||
"vega-util": "^1.15.0" | ||
"d3-array": "^2.7.0", | ||
"d3-interpolate": "^2.0.1", | ||
"vega-dataflow": "^5.7.2", | ||
"vega-scale": "^7.0.2", | ||
"vega-util": "^1.15.1" | ||
}, | ||
@@ -37,3 +37,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "28db83352e43e321dfe55fc5cb6489b211e45662" | ||
"gitHead": "8d6793f4ca7eaaf2d22186764e9ce2dae687cf52" | ||
} |
@@ -31,3 +31,3 @@ import {Transform} from 'vega-dataflow'; | ||
if (isArray(encode)) { | ||
if (out.changed() || encode.every(function(e) { return encoders[e]; })) { | ||
if (out.changed() || encode.every(e => encoders[e])) { | ||
encode = encode[0]; | ||
@@ -48,7 +48,7 @@ out.encode = null; // consume targeted encode directive | ||
if (pulse.changed(pulse.ADD)) { | ||
pulse.visit(pulse.ADD, function(t) { enter(t, _); update(t, _); }); | ||
pulse.visit(pulse.ADD, t => { enter(t, _); update(t, _); }); | ||
out.modifies(enter.output); | ||
out.modifies(update.output); | ||
if (set !== falsy && set !== update) { | ||
pulse.visit(pulse.ADD, function(t) { set(t, _); }); | ||
pulse.visit(pulse.ADD, t => { set(t, _); }); | ||
out.modifies(set.output); | ||
@@ -59,3 +59,3 @@ } | ||
if (pulse.changed(pulse.REM) && exit !== falsy) { | ||
pulse.visit(pulse.REM, function(t) { exit(t, _); }); | ||
pulse.visit(pulse.REM, t => { exit(t, _); }); | ||
out.modifies(exit.output); | ||
@@ -67,3 +67,3 @@ } | ||
if (reenter) { | ||
pulse.visit(flag, function(t) { | ||
pulse.visit(flag, t => { | ||
var mod = enter(t, _) || fmod; | ||
@@ -74,3 +74,3 @@ if (set(t, _) || mod) out.mod.push(t); | ||
} else { | ||
pulse.visit(flag, function(t) { | ||
pulse.visit(flag, t => { | ||
if (set(t, _) || fmod) out.mod.push(t); | ||
@@ -77,0 +77,0 @@ }); |
@@ -66,5 +66,3 @@ import {Transform, ingest} from 'vega-dataflow'; | ||
// compute size offset for legend entries | ||
offset = items.reduce(function(max, value) { | ||
return Math.max(max, size(value, _)); | ||
}, 0); | ||
offset = items.reduce((max, value) => Math.max(max, size(value, _)), 0); | ||
} else { | ||
@@ -71,0 +69,0 @@ size = constant(offset = size || 8); |
@@ -208,5 +208,3 @@ import {Transform} from 'vega-dataflow'; | ||
// if all pos or all neg, abs(sum) === domain.length | ||
var s = Math.abs(domain.reduce(function(s, v) { | ||
return s + (v < 0 ? -1 : v > 0 ? 1 : 0); | ||
}, 0)); | ||
var s = Math.abs(domain.reduce((s, v) => s + (v < 0 ? -1 : v > 0 ? 1 : 0), 0)); | ||
@@ -225,9 +223,10 @@ if (s !== domain.length) { | ||
// generate bin boundary array | ||
let domain = scale.domain(), | ||
lo = domain[0], | ||
hi = peek(domain), | ||
start = bins.start == null ? lo : bins.start, | ||
stop = bins.stop == null ? hi : bins.stop, | ||
step = bins.step; | ||
const domain = scale.domain(), | ||
lo = domain[0], | ||
hi = peek(domain), | ||
step = bins.step; | ||
let start = bins.start == null ? lo : bins.start, | ||
stop = bins.stop == null ? hi : bins.stop; | ||
if (!step) error('Scale bins parameter missing step property.'); | ||
@@ -234,0 +233,0 @@ if (start < lo) start = step * Math.ceil(lo / step); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83816
1876
+ Addedd3-color@2.0.0(transitive)
+ Addedd3-interpolate@2.0.1(transitive)
- Removedd3-color@1.4.1(transitive)
- Removedd3-interpolate@1.4.0(transitive)
Updatedd3-array@^2.7.0
Updatedd3-interpolate@^2.0.1
Updatedvega-dataflow@^5.7.2
Updatedvega-scale@^7.0.2
Updatedvega-util@^1.15.1