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 4.5.2 to 4.5.3

6

build/vega-encode.js

@@ -7,2 +7,6 @@ (function (global, factory) {

const defaultFormatter = value => vegaUtil.isArray(value)
? value.map(v => String(v))
: String(value);
/**

@@ -115,3 +119,3 @@ * Determine the tick count or interval function.

: specifier ? d3Format.format(specifier)
: String;
: defaultFormatter;

@@ -118,0 +122,0 @@ if (vegaScale.isLogarithmic(type)) {

2

build/vega-encode.min.js

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-scale"),require("vega-time"),require("vega-util"),require("d3-format"),require("vega-dataflow"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-scale","vega-time","vega-util","d3-format","vega-dataflow","d3-array","d3-interpolate"],n):n(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,(function(e,n,t,r,i,a,o,u){"use strict";function l(e,i,a){var o;return r.isNumber(i)&&(e.bins&&(i=Math.max(i,e.bins.length)),null!=a&&(i=Math.min(i,~~(r.span(e.domain())/a)||1))),r.isObject(i)&&(o=i.step,i=i.interval),r.isString(i)&&(i=e.type===n.Time?t.timeInterval(i):e.type==n.UTC?t.utcInterval(i):r.error("Only time and utc scales accept interval strings."),o&&(i=i.every(o))),i}function s(e,n,t){var i=e.range(),a=Math.floor(i[0]),o=Math.ceil(r.peek(i));if(a>o&&(i=o,o=a,a=i),n=n.filter((function(n){return n=e(n),a<=n&&n<=o})),t>0&&n.length>1){for(var u=[n[0],r.peek(n)];n.length>t&&n.length>=3;)n=n.filter((function(e,n){return!(n%2)}));n.length<3&&(n=u)}return n}function f(e,n){return e.bins?s(e,e.bins):e.ticks?e.ticks(n):e.domain()}function c(e,r,a,o,u){var l,s,f=e.type,c=f===n.Time||o===n.Time?t.timeFormat(a):f===n.UTC||o===n.UTC?t.utcFormat(a):e.tickFormat?e.tickFormat(r,a):a?i.format(a):String;if(n.isLogarithmic(f)){var d=function(e){var n=i.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return function(e,n){return function(t){var r,i,a=e(t),o=a.indexOf(n);if(o<0)return a;for(i=(r=function(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if((t=e.charCodeAt(r))>=48&&t<=57)return r+1}(a,o))<a.length?a.slice(r):"";--r>o;)if("0"!==a[r]){++r;break}return a.slice(0,r)+i}}(i.format(n),i.format(".1f")(1)[1])}return i.format(n)}(a);c=u||e.bins?d:(l=c,s=d,e=>l(e)?s(e):"")}return c}function d(e){a.Transform.call(this,null,e)}function m(e){a.Transform.call(this,null,e)}function p(){return a.ingest({})}function h(e){return e.exit}function g(e){a.Transform.call(this,null,e)}r.inherits(d,a.Transform).transform=function(e,n){if(this.value&&!e.modified())return n.StopPropagation;var t=n.fork(n.NO_SOURCE|n.NO_FIELDS),r=this.value,i=e.scale,o=l(i,null==e.count?e.values?e.values.length:10:e.count,e.minstep),u=e.format||c(i,o,e.formatSpecifier,e.formatType,!!e.values),d=e.values?s(i,e.values,o):f(i,o);return r&&(t.rem=r),r=d.map((function(e,n){return a.ingest({index:n/(d.length-1||1),value:e,label:u(e)})})),e.extra&&r.length&&r.push(a.ingest({index:-1,extra:{value:r[0].value},label:""})),t.source=r,t.add=r,this.value=r,t},r.inherits(m,a.Transform).transform=function(e,n){var t=n.dataflow,i=n.fork(n.NO_SOURCE|n.NO_FIELDS),o=e.item||p,u=e.key||a.tupleid,l=this.value;return r.isArray(i.encode)&&(i.encode=null),l&&(e.modified("key")||n.modified(u))&&r.error("DataJoin does not support modified key function or fields."),l||(n=n.addAll(),this.value=l=r.fastmap().test(h),l.lookup=function(e){return l.get(u(e))}),n.visit(n.ADD,(function(e){var n=u(e),t=l.get(n);t?t.exit?(l.empty--,i.add.push(t)):i.mod.push(t):(l.set(n,t=o(e)),i.add.push(t)),t.datum=e,t.exit=!1})),n.visit(n.MOD,(function(e){var n=u(e),t=l.get(n);t&&(t.datum=e,i.mod.push(t))})),n.visit(n.REM,(function(e){var n=u(e),t=l.get(n);e!==t.datum||t.exit||(i.rem.push(t),t.exit=!0,++l.empty)})),n.changed(n.ADD_MOD)&&i.modifies("datum"),e.clean&&l.empty>t.cleanThreshold&&t.runAfter(l.clean),i},r.inherits(g,a.Transform).transform=function(e,n){var t=n.fork(n.ADD_REM),i=e.mod||!1,a=e.encoders,o=n.encode;if(r.isArray(o)){if(!t.changed()&&!o.every((function(e){return a[e]})))return n.StopPropagation;o=o[0],t.encode=null}var u="enter"===o,l=a.update||r.falsy,s=a.enter||r.falsy,f=a.exit||r.falsy,c=(o&&!u?a[o]:l)||r.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,(function(n){s(n,e),l(n,e)})),t.modifies(s.output),t.modifies(l.output),c!==r.falsy&&c!==l&&(n.visit(n.ADD,(function(n){c(n,e)})),t.modifies(c.output))),n.changed(n.REM)&&f!==r.falsy&&(n.visit(n.REM,(function(n){f(n,e)})),t.modifies(f.output)),u||c!==r.falsy){var d=n.MOD|(e.modified()?n.REFLOW:0);u?(n.visit(d,(function(n){var r=s(n,e)||i;(c(n,e)||r)&&t.mod.push(n)})),t.mod.length&&t.modifies(s.output)):n.visit(d,(function(n){(c(n,e)||i)&&t.mod.push(n)})),t.mod.length&&t.modifies(c.output)}return t.changed()?t:n.StopPropagation};const v={[n.Quantile]:"quantiles",[n.Quantize]:"thresholds",[n.Threshold]:"domain"},y={[n.Quantile]:"quantiles",[n.Quantize]:"domain"};function M(e,t){return e.bins?function(e){const n=e.slice(0,-1);return n.max=r.peek(e),n}(e.bins):e.type===n.Log?function(e,n){var t=f(e,n),r=e.base(),i=Math.log(r),a=Math.max(1,r*n/t.length);return t.filter(e=>{var n=e/Math.pow(r,Math.round(Math.log(e)/i));return n*r<r-.5&&(n*=r),n<=a})}(e,t):v[e.type]?function(e){const n=[-1/0].concat(e);return n.max=1/0,n}(e[v[e.type]]()):f(e,t)}function b(e,t,r,i,a,o){const u=y[e.type]&&a!==n.Time&&a!==n.UTC?function(e,t){var r,i=e[y[e.type]](),a=i.length,o=a>1?i[1]-i[0]:i[0];for(r=1;r<a;++r)o=Math.min(o,i[r]-i[r-1]);return n.tickFormat(0,o,30,t)}(e,i):c(e,t,i,a,o);return"symbol"===r&&function(e){return v[e.type]||e.bins}(e)?function(e){return function(n,t,r){var i=x(r[t+1],x(r.max,1/0)),a=S(n,e),o=S(i,e);return a&&o?a+" – "+o:o?"< "+o:"≥ "+a}}(u):"discrete"===r?function(e){return function(n,t){return t?e(n):null}}(u):function(e){return function(n){return e(n)}}(u)}function x(e,n){return null!=e?e:n}function S(e,n){return Number.isFinite(e)?n(e):null}function T(e){a.Transform.call(this,[],e)}r.inherits(T,a.Transform).transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var i,o,u,s,f,c=t.fork(t.NO_SOURCE|t.NO_FIELDS),d=this.value,m=e.type||"symbol",p=e.scale,h=+e.limit,g=l(p,null==e.count?5:e.count,e.minstep),v=!!e.values||"symbol"===m,y=e.format||b(p,g,m,e.formatSpecifier,e.formatType,v),x=e.values||M(p,g);return d&&(c.rem=d),"symbol"===m?(h&&x.length>h?(t.dataflow.warn("Symbol legend count exceeds limit, filtering items."),d=x.slice(0,h-1),f=!0):d=x,r.isFunction(u=e.size)?(e.values||0!==p(d[0])||(d=d.slice(1)),s=d.reduce((function(n,t){return Math.max(n,u(t,e))}),0)):u=r.constant(s=u||8),d=d.map((function(n,t){return a.ingest({index:t,label:y(n,t,d),value:n,offset:s,size:u(n,e)})})),f&&(f=x[d.length],d.push(a.ingest({index:d.length,label:`…${x.length-d.length} entries`,value:f,offset:s,size:u(f,e)})))):"gradient"===m?(i=p.domain(),o=n.scaleFraction(p,i[0],r.peek(i)),x.length<3&&!e.values&&i[0]!==r.peek(i)&&(x=[i[0],r.peek(i)]),d=x.map((function(e,n){return a.ingest({index:n,label:y(e,n,x),value:e,perc:o(e)})}))):(u=x.length-1,o=function(e){var t=e.domain(),i=t.length-1,a=+t[0],o=+r.peek(t),u=o-a;if(e.type===n.Threshold){var l=i?u/i:.1;u=(o+=l)-(a-=l)}return function(e){return(e-a)/u}}(p),d=x.map((function(e,n){return a.ingest({index:n,label:y(e,n,x),value:e,perc:n?o(e):0,perc2:n===u?1:o(x[n+1])})}))),c.source=d,c.add=d,this.value=d,c};var k=r.fastmap({line:z,"line-radial":function(e,n,t,r){return z(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},arc:L,"arc-radial":function(e,n,t,r){return L(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},curve:F,"curve-radial":function(e,n,t,r){return F(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},"orthogonal-horizontal":function(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t},"orthogonal-vertical":function(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r},"orthogonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*i+","+n*a+"A"+n+","+n+" 0 0,"+(l?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u},"diagonal-horizontal":function(e,n,t,r){var i=(e+t)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+r+" "+t+","+r},"diagonal-vertical":function(e,n,t,r){var i=(n+r)/2;return"M"+e+","+n+"C"+e+","+i+" "+t+","+i+" "+t+","+r},"diagonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=(n+r)/2;return"M"+n*i+","+n*a+"C"+l*i+","+l*a+" "+l*o+","+l*u+" "+r*o+","+r*u}});function O(e){return e.source.x}function D(e){return e.source.y}function w(e){return e.target.x}function A(e){return e.target.y}function C(e){a.Transform.call(this,{},e)}function z(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function L(e,n,t,r){var i=t-e,a=r-n,o=Math.sqrt(i*i+a*a)/2;return"M"+e+","+n+"A"+o+","+o+" "+180*Math.atan2(a,i)/Math.PI+" 0 1 "+t+","+r}function F(e,n,t,r){var i=t-e,a=r-n,o=.2*(i+a),u=.2*(a-i);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function q(e){a.Transform.call(this,null,e)}C.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"}]},r.inherits(C,a.Transform).transform=function(e,n){var t=e.sourceX||O,i=e.sourceY||D,a=e.targetX||w,o=e.targetY||A,u=e.as||"path",l=e.orient||"vertical",s=e.shape||"line",f=k.get(s+"-"+l)||k.get(s);return f||r.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),n.visit(n.SOURCE,(function(e){e[u]=f(t(e),i(e),a(e),o(e))})),n.reflow(e.modified()).modifies(u)},q.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"]}]},r.inherits(q,a.Transform).transform=function(e,n){var t,i,a,u=e.as||["startAngle","endAngle"],l=u[0],s=u[1],f=e.field||r.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,g=c,v=(d-c)/o.sum(p),y=o.range(h);for(e.sort&&y.sort((function(e,n){return p[e]-p[n]})),t=0;t<h;++t)a=p[y[t]],(i=m[y[t]])[l]=g,i[s]=g+=a*v;return this.value=p,n.reflow(e.modified()).modifies(u)};function I(e){return n.isContinuous(e)&&e!==n.Sequential}var P=r.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function E(e){a.Transform.call(this,null,e),this.modified(!0)}function R(e,t,i){n.isLogarithmic(e)&&(Math.abs(t.reduce((function(e,n){return e+(n<0?-1:n>0?1:0)}),0))!==t.length&&i.warn("Log scale domain includes zero: "+r.stringValue(t)));return t}function U(e,t,i){return r.isFunction(e)&&(t||i)?n.interpolateRange(e,_(t||[0,1],i)):e}function _(e,n){return n?e.slice().reverse():e}function N(e){a.Transform.call(this,null,e)}r.inherits(E,a.Transform).transform=function(e,t){var i=t.dataflow,a=this.value,s=function(e){var t,i=e.type,a="";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(r.isString))})(e)&&(t=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0,a=2===t?n.Sequential+"-":3===t?n.Diverging+"-":"");return(a+i||n.Linear).toLowerCase()}(e);for(s in a&&s===a.type||(this.value=a=n.scale(s)()),e)if(!P[s]){if("padding"===s&&I(a.type))continue;r.isFunction(a[s])?a[s](e[s]):i.warn("Unsupported scale property: "+s)}return function(e,t,i){var a=e.type,o=t.round||!1,l=t.range;if(null!=t.rangeStep)l=function(e,t,i){e!==n.Band&&e!==n.Point&&r.error("Only band and point scales support rangeStep.");var a=(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,a)]}(a,t,i);else if(t.scheme&&(l=function(e,t,i){var a,o,u=t.schemeExtent;r.isArray(t.scheme)?o=n.interpolateColors(t.scheme,t.interpolate,t.interpolateGamma):(a=t.scheme.toLowerCase(),(o=n.scheme(a))||r.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)?U(o,u,t.reverse):r.isFunction(o)?n.quantizeInterpolator(U(o,u),i):e===n.Ordinal?o:o.slice(0,i)}(a,t,i),r.isFunction(l))){if(e.interpolator)return e.interpolator(l);r.error(`Scale type ${a} does not support interpolating color schemes.`)}if(l&&n.isInterpolating(a))return e.interpolator(n.interpolateColors(_(l,t.reverse),t.interpolate,t.interpolateGamma));l&&t.interpolate&&e.interpolate?e.interpolate(n.interpolate(t.interpolate,t.interpolateGamma)):r.isFunction(e.round)?e.round(o):r.isFunction(e.rangeRound)&&e.interpolate(o?u.interpolateRound:u.interpolate);l&&e.range(_(l,t.reverse))}(a,e,function(e,t,i){let a=t.bins;if(a&&!r.isArray(a)){let n=e.domain(),t=n[0],i=r.peek(n),u=null==a.start?t:a.start,l=null==a.stop?i:a.stop,s=a.step;s||r.error("Scale bins parameter missing step property."),u<t&&(u=s*Math.ceil(t/s)),l>i&&(l=s*Math.floor(i/s)),a=o.range(u,l+s/2,s)}a?e.bins=a:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(a?t.domain||t.domainRaw||(e.domain(a),i=a.length):e.bins=e.domain());return i}(a,e,function(e,t,i){var a=function(e,n,t){return n?(e.domain(R(e.type,n,t)),n.length):-1}(e,t.domainRaw,i);if(a>-1)return a;var o,u,s=t.domain,f=e.type,c=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;I(f)&&t.padding&&s[0]!==r.peek(s)&&(s=function(e,t,i,a,o,u){var l=Math.abs(r.peek(i)-i[0]),s=l/(l-2*a),f=e===n.Log?r.zoomLog(t,null,s):e===n.Sqrt?r.zoomPow(t,null,s,.5):e===n.Pow?r.zoomPow(t,null,s,o||1):e===n.Symlog?r.zoomSymlog(t,null,s,u||1):r.zoomLinear(t,null,s);return(t=t.slice())[0]=f[0],t[t.length-1]=f[1],t}(f,s,t.range,t.padding,t.exponent,t.constant));(c||null!=t.domainMin||null!=t.domainMax||null!=t.domainMid)&&(o=(s=s.slice()).length-1||1,c&&(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&&(((u=t.domainMid)<s[0]||u>s[o])&&i.warn("Scale domainMid exceeds domain min or max.",u),s.splice(o,0,u)));e.domain(R(f,s,i)),f===n.Ordinal&&e.unknown(t.domainImplicit?n.scaleImplicit:void 0);t.nice&&e.nice&&e.nice(!0!==t.nice&&l(e,t.nice)||null);return s.length}(a,e,i))),t.fork(t.NO_SOURCE|t.NO_FIELDS)},r.inherits(N,a.Transform).transform=function(e,n){var t=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return t&&n.source.sort(a.stableCompare(e.sort)),this.modified(t),n};var Q=["y0","y1"];function j(e){a.Transform.call(this,null,e)}function G(e,n,t,r,i){for(var a,o=(n-e.sum)/2,u=e.length,l=0;l<u;++l)(a=e[l])[r]=o,a[i]=o+=Math.abs(t(a))}function X(e,n,t,r,i){for(var a,o=1/e.sum,u=0,l=e.length,s=0,f=0;s<l;++s)(a=e[s])[r]=u,a[i]=u=o*(f+=Math.abs(t(a)))}function Y(e,n,t,r,i){for(var a,o,u=0,l=0,s=e.length,f=0;f<s;++f)(a=+t(o=e[f]))<0?(o[r]=l,o[i]=l+=a):(o[r]=u,o[i]=u+=a)}j.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:Q}]},r.inherits(j,a.Transform).transform=function(e,n){var t,i,o,u,l=e.as||Q,s=l[0],f=l[1],c=a.stableCompare(e.sort),d=e.field||r.one,m="center"===e.offset?G:"normalize"===e.offset?X:Y;for(t=function(e,n,t,r){var i,a,o,u,l,s,f,c,d,m=[],p=function(e){return e(l)};if(null==n)m.push(e.slice());else for(i={},a=0,o=e.length;a<o;++a)l=e[a],s=n.map(p),(f=i[s])||(i[s]=f=[],m.push(f)),f.push(l);for(s=0,d=0,u=m.length;s<u;++s){for(f=m[s],a=0,c=0,o=f.length;a<o;++a)c+=Math.abs(r(f[a]));f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}(n.source,e.groupby,c,d),i=0,o=t.length,u=t.max;i<o;++i)m(t[i],u,d,s,f);return n.reflow(e.modified()).modifies(l)},e.axisticks=d,e.datajoin=m,e.encode=g,e.legendentries=T,e.linkpath=C,e.pie=q,e.scale=E,e.sortitems=N,e.stack=j,e.validTicks=s,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-scale"),require("vega-time"),require("vega-util"),require("d3-format"),require("vega-dataflow"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-scale","vega-time","vega-util","d3-format","vega-dataflow","d3-array","d3-interpolate"],n):n(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,(function(e,n,t,r,i,a,o,u){"use strict";const l=e=>r.isArray(e)?e.map(e=>String(e)):String(e);function s(e,i,a){var o;return r.isNumber(i)&&(e.bins&&(i=Math.max(i,e.bins.length)),null!=a&&(i=Math.min(i,~~(r.span(e.domain())/a)||1))),r.isObject(i)&&(o=i.step,i=i.interval),r.isString(i)&&(i=e.type===n.Time?t.timeInterval(i):e.type==n.UTC?t.utcInterval(i):r.error("Only time and utc scales accept interval strings."),o&&(i=i.every(o))),i}function f(e,n,t){var i=e.range(),a=Math.floor(i[0]),o=Math.ceil(r.peek(i));if(a>o&&(i=o,o=a,a=i),n=n.filter((function(n){return n=e(n),a<=n&&n<=o})),t>0&&n.length>1){for(var u=[n[0],r.peek(n)];n.length>t&&n.length>=3;)n=n.filter((function(e,n){return!(n%2)}));n.length<3&&(n=u)}return n}function c(e,n){return e.bins?f(e,e.bins):e.ticks?e.ticks(n):e.domain()}function d(e,r,a,o,u){var s,f,c=e.type,d=c===n.Time||o===n.Time?t.timeFormat(a):c===n.UTC||o===n.UTC?t.utcFormat(a):e.tickFormat?e.tickFormat(r,a):a?i.format(a):l;if(n.isLogarithmic(c)){var m=function(e){var n=i.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return function(e,n){return function(t){var r,i,a=e(t),o=a.indexOf(n);if(o<0)return a;for(i=(r=function(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if((t=e.charCodeAt(r))>=48&&t<=57)return r+1}(a,o))<a.length?a.slice(r):"";--r>o;)if("0"!==a[r]){++r;break}return a.slice(0,r)+i}}(i.format(n),i.format(".1f")(1)[1])}return i.format(n)}(a);d=u||e.bins?m:(s=d,f=m,e=>s(e)?f(e):"")}return d}function m(e){a.Transform.call(this,null,e)}function p(e){a.Transform.call(this,null,e)}function h(){return a.ingest({})}function g(e){return e.exit}function v(e){a.Transform.call(this,null,e)}r.inherits(m,a.Transform).transform=function(e,n){if(this.value&&!e.modified())return n.StopPropagation;var t=n.fork(n.NO_SOURCE|n.NO_FIELDS),r=this.value,i=e.scale,o=s(i,null==e.count?e.values?e.values.length:10:e.count,e.minstep),u=e.format||d(i,o,e.formatSpecifier,e.formatType,!!e.values),l=e.values?f(i,e.values,o):c(i,o);return r&&(t.rem=r),r=l.map((function(e,n){return a.ingest({index:n/(l.length-1||1),value:e,label:u(e)})})),e.extra&&r.length&&r.push(a.ingest({index:-1,extra:{value:r[0].value},label:""})),t.source=r,t.add=r,this.value=r,t},r.inherits(p,a.Transform).transform=function(e,n){var t=n.dataflow,i=n.fork(n.NO_SOURCE|n.NO_FIELDS),o=e.item||h,u=e.key||a.tupleid,l=this.value;return r.isArray(i.encode)&&(i.encode=null),l&&(e.modified("key")||n.modified(u))&&r.error("DataJoin does not support modified key function or fields."),l||(n=n.addAll(),this.value=l=r.fastmap().test(g),l.lookup=function(e){return l.get(u(e))}),n.visit(n.ADD,(function(e){var n=u(e),t=l.get(n);t?t.exit?(l.empty--,i.add.push(t)):i.mod.push(t):(l.set(n,t=o(e)),i.add.push(t)),t.datum=e,t.exit=!1})),n.visit(n.MOD,(function(e){var n=u(e),t=l.get(n);t&&(t.datum=e,i.mod.push(t))})),n.visit(n.REM,(function(e){var n=u(e),t=l.get(n);e!==t.datum||t.exit||(i.rem.push(t),t.exit=!0,++l.empty)})),n.changed(n.ADD_MOD)&&i.modifies("datum"),e.clean&&l.empty>t.cleanThreshold&&t.runAfter(l.clean),i},r.inherits(v,a.Transform).transform=function(e,n){var t=n.fork(n.ADD_REM),i=e.mod||!1,a=e.encoders,o=n.encode;if(r.isArray(o)){if(!t.changed()&&!o.every((function(e){return a[e]})))return n.StopPropagation;o=o[0],t.encode=null}var u="enter"===o,l=a.update||r.falsy,s=a.enter||r.falsy,f=a.exit||r.falsy,c=(o&&!u?a[o]:l)||r.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,(function(n){s(n,e),l(n,e)})),t.modifies(s.output),t.modifies(l.output),c!==r.falsy&&c!==l&&(n.visit(n.ADD,(function(n){c(n,e)})),t.modifies(c.output))),n.changed(n.REM)&&f!==r.falsy&&(n.visit(n.REM,(function(n){f(n,e)})),t.modifies(f.output)),u||c!==r.falsy){var d=n.MOD|(e.modified()?n.REFLOW:0);u?(n.visit(d,(function(n){var r=s(n,e)||i;(c(n,e)||r)&&t.mod.push(n)})),t.mod.length&&t.modifies(s.output)):n.visit(d,(function(n){(c(n,e)||i)&&t.mod.push(n)})),t.mod.length&&t.modifies(c.output)}return t.changed()?t:n.StopPropagation};const y={[n.Quantile]:"quantiles",[n.Quantize]:"thresholds",[n.Threshold]:"domain"},M={[n.Quantile]:"quantiles",[n.Quantize]:"domain"};function b(e,t){return e.bins?function(e){const n=e.slice(0,-1);return n.max=r.peek(e),n}(e.bins):e.type===n.Log?function(e,n){var t=c(e,n),r=e.base(),i=Math.log(r),a=Math.max(1,r*n/t.length);return t.filter(e=>{var n=e/Math.pow(r,Math.round(Math.log(e)/i));return n*r<r-.5&&(n*=r),n<=a})}(e,t):y[e.type]?function(e){const n=[-1/0].concat(e);return n.max=1/0,n}(e[y[e.type]]()):c(e,t)}function x(e,t,r,i,a,o){const u=M[e.type]&&a!==n.Time&&a!==n.UTC?function(e,t){var r,i=e[M[e.type]](),a=i.length,o=a>1?i[1]-i[0]:i[0];for(r=1;r<a;++r)o=Math.min(o,i[r]-i[r-1]);return n.tickFormat(0,o,30,t)}(e,i):d(e,t,i,a,o);return"symbol"===r&&function(e){return y[e.type]||e.bins}(e)?function(e){return function(n,t,r){var i=S(r[t+1],S(r.max,1/0)),a=T(n,e),o=T(i,e);return a&&o?a+" – "+o:o?"< "+o:"≥ "+a}}(u):"discrete"===r?function(e){return function(n,t){return t?e(n):null}}(u):function(e){return function(n){return e(n)}}(u)}function S(e,n){return null!=e?e:n}function T(e,n){return Number.isFinite(e)?n(e):null}function k(e){a.Transform.call(this,[],e)}r.inherits(k,a.Transform).transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var i,o,u,l,f,c=t.fork(t.NO_SOURCE|t.NO_FIELDS),d=this.value,m=e.type||"symbol",p=e.scale,h=+e.limit,g=s(p,null==e.count?5:e.count,e.minstep),v=!!e.values||"symbol"===m,y=e.format||x(p,g,m,e.formatSpecifier,e.formatType,v),M=e.values||b(p,g);return d&&(c.rem=d),"symbol"===m?(h&&M.length>h?(t.dataflow.warn("Symbol legend count exceeds limit, filtering items."),d=M.slice(0,h-1),f=!0):d=M,r.isFunction(u=e.size)?(e.values||0!==p(d[0])||(d=d.slice(1)),l=d.reduce((function(n,t){return Math.max(n,u(t,e))}),0)):u=r.constant(l=u||8),d=d.map((function(n,t){return a.ingest({index:t,label:y(n,t,d),value:n,offset:l,size:u(n,e)})})),f&&(f=M[d.length],d.push(a.ingest({index:d.length,label:`…${M.length-d.length} entries`,value:f,offset:l,size:u(f,e)})))):"gradient"===m?(i=p.domain(),o=n.scaleFraction(p,i[0],r.peek(i)),M.length<3&&!e.values&&i[0]!==r.peek(i)&&(M=[i[0],r.peek(i)]),d=M.map((function(e,n){return a.ingest({index:n,label:y(e,n,M),value:e,perc:o(e)})}))):(u=M.length-1,o=function(e){var t=e.domain(),i=t.length-1,a=+t[0],o=+r.peek(t),u=o-a;if(e.type===n.Threshold){var l=i?u/i:.1;u=(o+=l)-(a-=l)}return function(e){return(e-a)/u}}(p),d=M.map((function(e,n){return a.ingest({index:n,label:y(e,n,M),value:e,perc:n?o(e):0,perc2:n===u?1:o(M[n+1])})}))),c.source=d,c.add=d,this.value=d,c};var O=r.fastmap({line:L,"line-radial":function(e,n,t,r){return L(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},arc:F,"arc-radial":function(e,n,t,r){return F(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},curve:q,"curve-radial":function(e,n,t,r){return q(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},"orthogonal-horizontal":function(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t},"orthogonal-vertical":function(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r},"orthogonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*i+","+n*a+"A"+n+","+n+" 0 0,"+(l?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u},"diagonal-horizontal":function(e,n,t,r){var i=(e+t)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+r+" "+t+","+r},"diagonal-vertical":function(e,n,t,r){var i=(n+r)/2;return"M"+e+","+n+"C"+e+","+i+" "+t+","+i+" "+t+","+r},"diagonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=(n+r)/2;return"M"+n*i+","+n*a+"C"+l*i+","+l*a+" "+l*o+","+l*u+" "+r*o+","+r*u}});function D(e){return e.source.x}function w(e){return e.source.y}function A(e){return e.target.x}function C(e){return e.target.y}function z(e){a.Transform.call(this,{},e)}function L(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function F(e,n,t,r){var i=t-e,a=r-n,o=Math.sqrt(i*i+a*a)/2;return"M"+e+","+n+"A"+o+","+o+" "+180*Math.atan2(a,i)/Math.PI+" 0 1 "+t+","+r}function q(e,n,t,r){var i=t-e,a=r-n,o=.2*(i+a),u=.2*(a-i);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function I(e){a.Transform.call(this,null,e)}z.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"}]},r.inherits(z,a.Transform).transform=function(e,n){var t=e.sourceX||D,i=e.sourceY||w,a=e.targetX||A,o=e.targetY||C,u=e.as||"path",l=e.orient||"vertical",s=e.shape||"line",f=O.get(s+"-"+l)||O.get(s);return f||r.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),n.visit(n.SOURCE,(function(e){e[u]=f(t(e),i(e),a(e),o(e))})),n.reflow(e.modified()).modifies(u)},I.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"]}]},r.inherits(I,a.Transform).transform=function(e,n){var t,i,a,u=e.as||["startAngle","endAngle"],l=u[0],s=u[1],f=e.field||r.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,g=c,v=(d-c)/o.sum(p),y=o.range(h);for(e.sort&&y.sort((function(e,n){return p[e]-p[n]})),t=0;t<h;++t)a=p[y[t]],(i=m[y[t]])[l]=g,i[s]=g+=a*v;return this.value=p,n.reflow(e.modified()).modifies(u)};function P(e){return n.isContinuous(e)&&e!==n.Sequential}var E=r.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function R(e){a.Transform.call(this,null,e),this.modified(!0)}function U(e,t,i){n.isLogarithmic(e)&&(Math.abs(t.reduce((function(e,n){return e+(n<0?-1:n>0?1:0)}),0))!==t.length&&i.warn("Log scale domain includes zero: "+r.stringValue(t)));return t}function _(e,t,i){return r.isFunction(e)&&(t||i)?n.interpolateRange(e,N(t||[0,1],i)):e}function N(e,n){return n?e.slice().reverse():e}function Q(e){a.Transform.call(this,null,e)}r.inherits(R,a.Transform).transform=function(e,t){var i=t.dataflow,a=this.value,l=function(e){var t,i=e.type,a="";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(r.isString))})(e)&&(t=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0,a=2===t?n.Sequential+"-":3===t?n.Diverging+"-":"");return(a+i||n.Linear).toLowerCase()}(e);for(l in a&&l===a.type||(this.value=a=n.scale(l)()),e)if(!E[l]){if("padding"===l&&P(a.type))continue;r.isFunction(a[l])?a[l](e[l]):i.warn("Unsupported scale property: "+l)}return function(e,t,i){var a=e.type,o=t.round||!1,l=t.range;if(null!=t.rangeStep)l=function(e,t,i){e!==n.Band&&e!==n.Point&&r.error("Only band and point scales support rangeStep.");var a=(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,a)]}(a,t,i);else if(t.scheme&&(l=function(e,t,i){var a,o,u=t.schemeExtent;r.isArray(t.scheme)?o=n.interpolateColors(t.scheme,t.interpolate,t.interpolateGamma):(a=t.scheme.toLowerCase(),(o=n.scheme(a))||r.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)?_(o,u,t.reverse):r.isFunction(o)?n.quantizeInterpolator(_(o,u),i):e===n.Ordinal?o:o.slice(0,i)}(a,t,i),r.isFunction(l))){if(e.interpolator)return e.interpolator(l);r.error(`Scale type ${a} does not support interpolating color schemes.`)}if(l&&n.isInterpolating(a))return e.interpolator(n.interpolateColors(N(l,t.reverse),t.interpolate,t.interpolateGamma));l&&t.interpolate&&e.interpolate?e.interpolate(n.interpolate(t.interpolate,t.interpolateGamma)):r.isFunction(e.round)?e.round(o):r.isFunction(e.rangeRound)&&e.interpolate(o?u.interpolateRound:u.interpolate);l&&e.range(N(l,t.reverse))}(a,e,function(e,t,i){let a=t.bins;if(a&&!r.isArray(a)){let n=e.domain(),t=n[0],i=r.peek(n),u=null==a.start?t:a.start,l=null==a.stop?i:a.stop,s=a.step;s||r.error("Scale bins parameter missing step property."),u<t&&(u=s*Math.ceil(t/s)),l>i&&(l=s*Math.floor(i/s)),a=o.range(u,l+s/2,s)}a?e.bins=a:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(a?t.domain||t.domainRaw||(e.domain(a),i=a.length):e.bins=e.domain());return i}(a,e,function(e,t,i){var a=function(e,n,t){return n?(e.domain(U(e.type,n,t)),n.length):-1}(e,t.domainRaw,i);if(a>-1)return a;var o,u,l=t.domain,f=e.type,c=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(!l)return 0;P(f)&&t.padding&&l[0]!==r.peek(l)&&(l=function(e,t,i,a,o,u){var l=Math.abs(r.peek(i)-i[0]),s=l/(l-2*a),f=e===n.Log?r.zoomLog(t,null,s):e===n.Sqrt?r.zoomPow(t,null,s,.5):e===n.Pow?r.zoomPow(t,null,s,o||1):e===n.Symlog?r.zoomSymlog(t,null,s,u||1):r.zoomLinear(t,null,s);return(t=t.slice())[0]=f[0],t[t.length-1]=f[1],t}(f,l,t.range,t.padding,t.exponent,t.constant));(c||null!=t.domainMin||null!=t.domainMax||null!=t.domainMid)&&(o=(l=l.slice()).length-1||1,c&&(l[0]>0&&(l[0]=0),l[o]<0&&(l[o]=0)),null!=t.domainMin&&(l[0]=t.domainMin),null!=t.domainMax&&(l[o]=t.domainMax),null!=t.domainMid&&(((u=t.domainMid)<l[0]||u>l[o])&&i.warn("Scale domainMid exceeds domain min or max.",u),l.splice(o,0,u)));e.domain(U(f,l,i)),f===n.Ordinal&&e.unknown(t.domainImplicit?n.scaleImplicit:void 0);t.nice&&e.nice&&e.nice(!0!==t.nice&&s(e,t.nice)||null);return l.length}(a,e,i))),t.fork(t.NO_SOURCE|t.NO_FIELDS)},r.inherits(Q,a.Transform).transform=function(e,n){var t=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return t&&n.source.sort(a.stableCompare(e.sort)),this.modified(t),n};var j=["y0","y1"];function G(e){a.Transform.call(this,null,e)}function X(e,n,t,r,i){for(var a,o=(n-e.sum)/2,u=e.length,l=0;l<u;++l)(a=e[l])[r]=o,a[i]=o+=Math.abs(t(a))}function Y(e,n,t,r,i){for(var a,o=1/e.sum,u=0,l=e.length,s=0,f=0;s<l;++s)(a=e[s])[r]=u,a[i]=u=o*(f+=Math.abs(t(a)))}function B(e,n,t,r,i){for(var a,o,u=0,l=0,s=e.length,f=0;f<s;++f)(a=+t(o=e[f]))<0?(o[r]=l,o[i]=l+=a):(o[r]=u,o[i]=u+=a)}G.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:j}]},r.inherits(G,a.Transform).transform=function(e,n){var t,i,o,u,l=e.as||j,s=l[0],f=l[1],c=a.stableCompare(e.sort),d=e.field||r.one,m="center"===e.offset?X:"normalize"===e.offset?Y:B;for(t=function(e,n,t,r){var i,a,o,u,l,s,f,c,d,m=[],p=function(e){return e(l)};if(null==n)m.push(e.slice());else for(i={},a=0,o=e.length;a<o;++a)l=e[a],s=n.map(p),(f=i[s])||(i[s]=f=[],m.push(f)),f.push(l);for(s=0,d=0,u=m.length;s<u;++s){for(f=m[s],a=0,c=0,o=f.length;a<o;++a)c+=Math.abs(r(f[a]));f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}(n.source,e.groupby,c,d),i=0,o=t.length,u=t.max;i<o;++i)m(t[i],u,d,s,f);return n.reflow(e.modified()).modifies(l)},e.axisticks=m,e.datajoin=p,e.encode=v,e.legendentries=k,e.linkpath=z,e.pie=I,e.scale=R,e.sortitems=Q,e.stack=G,e.validTicks=f,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "vega-encode",
"version": "4.5.2",
"version": "4.5.3",
"description": "Visual encoding transforms for Vega dataflows.",

@@ -28,3 +28,3 @@ "keywords": [

"d3-array": "^2.4.0",
"d3-format": "^1.4.2",
"d3-format": "^1.4.3",
"d3-interpolate": "^1.4.0",

@@ -34,3 +34,3 @@ "vega-dataflow": "^5.5.0",

"vega-time": "^1.0.0",
"vega-util": "^1.12.2"
"vega-util": "^1.13.1"
},

@@ -40,3 +40,3 @@ "devDependencies": {

},
"gitHead": "178cab5429841aaf02d164753a0621e89d1dce9a"
"gitHead": "2485e6f68a1cec25260c8c07b812f24925c5d726"
}
import {isLogarithmic, Time, UTC} from 'vega-scale';
import {timeFormat, timeInterval, utcFormat, utcInterval} from 'vega-time';
import {error, isNumber, isObject, isString, peek, span} from 'vega-util';
import {error, isArray, isNumber, isObject, isString, peek, span} from 'vega-util';
import {format as numberFormat, formatSpecifier} from 'd3-format';
const defaultFormatter = value => isArray(value)
? value.map(v => String(v))
: String(value);
/**

@@ -113,3 +117,3 @@ * Determine the tick count or interval function.

: specifier ? numberFormat(specifier)
: String;
: defaultFormatter;

@@ -116,0 +120,0 @@ if (isLogarithmic(type)) {

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