UNPKG

22.6 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-scale"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scale","vega-util"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega,e.vega)}(this,(function(e,t,n,r){"use strict";function a(e){t.Transform.call(this,null,e)}function i(e){t.Transform.call(this,null,e)}function o(){return t.ingest({})}function l(e){t.Transform.call(this,null,e)}function s(e){t.Transform.call(this,[],e)}r.inherits(a,t.Transform,{transform(e,r){if(this.value&&!e.modified())return r.StopPropagation;var a=r.dataflow.locale(),i=r.fork(r.NO_SOURCE|r.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),c=e.format||n.tickFormat(a,l,u,e.formatSpecifier,e.formatType,!!e.values),d=e.values?n.validTicks(l,e.values,u):n.tickValues(l,u);return o&&(i.rem=o),o=d.map(((e,n)=>t.ingest({index:n/(d.length-1||1),value:e,label:c(e)}))),e.extra&&o.length&&o.push(t.ingest({index:-1,extra:{value:o[0].value},label:""})),i.source=o,i.add=o,this.value=o,i}}),r.inherits(i,t.Transform,{transform(e,n){var a=n.dataflow,i=n.fork(n.NO_SOURCE|n.NO_FIELDS),l=e.item||o,s=e.key||t.tupleid,u=this.value;return r.isArray(i.encode)&&(i.encode=null),u&&(e.modified("key")||n.modified(s))&&r.error("DataJoin does not support modified key function or fields."),u||(n=n.addAll(),this.value=u=function(e){const t=r.fastmap().test((e=>e.exit));return t.lookup=n=>t.get(e(n)),t}(s)),n.visit(n.ADD,(e=>{const t=s(e);let n=u.get(t);n?n.exit?(u.empty--,i.add.push(n)):i.mod.push(n):(n=l(e),u.set(t,n),i.add.push(n)),n.datum=e,n.exit=!1})),n.visit(n.MOD,(e=>{const t=s(e),n=u.get(t);n&&(n.datum=e,i.mod.push(n))})),n.visit(n.REM,(e=>{const t=s(e),n=u.get(t);e!==n.datum||n.exit||(i.rem.push(n),n.exit=!0,++u.empty)})),n.changed(n.ADD_MOD)&&i.modifies("datum"),(n.clean()||e.clean&&u.empty>a.cleanThreshold)&&a.runAfter(u.clean),i}}),r.inherits(l,t.Transform,{transform(e,t){var n=t.fork(t.ADD_REM),a=e.mod||!1,i=e.encoders,o=t.encode;if(r.isArray(o)){if(!n.changed()&&!o.every((e=>i[e])))return t.StopPropagation;o=o[0],n.encode=null}var l="enter"===o,s=i.update||r.falsy,u=i.enter||r.falsy,c=i.exit||r.falsy,d=(o&&!l?i[o]:s)||r.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),d!==r.falsy&&d!==s&&(t.visit(t.ADD,(t=>{d(t,e)})),n.modifies(d.output))),t.changed(t.REM)&&c!==r.falsy&&(t.visit(t.REM,(t=>{c(t,e)})),n.modifies(c.output)),l||d!==r.falsy){const r=t.MOD|(e.modified()?t.REFLOW:0);l?(t.visit(r,(t=>{const r=u(t,e)||a;(d(t,e)||r)&&n.mod.push(t)})),n.mod.length&&n.modifies(u.output)):t.visit(r,(t=>{(d(t,e)||a)&&n.mod.push(t)})),n.mod.length&&n.modifies(d.output)}return n.changed()?n:t.StopPropagation}}),r.inherits(s,t.Transform,{transform(e,a){if(null!=this.value&&!e.modified())return a.StopPropagation;var i,o,l,s,u,c=a.dataflow.locale(),d=a.fork(a.NO_SOURCE|a.NO_FIELDS),f=this.value,h=e.type||n.SymbolLegend,m=e.scale,g=+e.limit,p=n.tickCount(m,null==e.count?5:e.count,e.minstep),y=!!e.values||h===n.SymbolLegend,v=e.format||n.labelFormat(c,m,p,h,e.formatSpecifier,e.formatType,y),b=e.values||n.labelValues(m,p);return f&&(d.rem=f),h===n.SymbolLegend?(g&&b.length>g?(a.dataflow.warn("Symbol legend count exceeds limit, filtering items."),f=b.slice(0,g-1),u=!0):f=b,r.isFunction(l=e.size)?(e.values||0!==m(f[0])||(f=f.slice(1)),s=f.reduce(((t,n)=>Math.max(t,l(n,e))),0)):l=r.constant(s=l||8),f=f.map(((n,r)=>t.ingest({index:r,label:v(n,r,f),value:n,offset:s,size:l(n,e)}))),u&&(u=b[f.length],f.push(t.ingest({index:f.length,label:"…".concat(b.length-f.length," entries"),value:u,offset:s,size:l(u,e)})))):h===n.GradientLegend?(i=m.domain(),o=n.scaleFraction(m,i[0],r.peek(i)),b.length<3&&!e.values&&i[0]!==r.peek(i)&&(b=[i[0],r.peek(i)]),f=b.map(((e,n)=>t.ingest({index:n,label:v(e,n,b),value:e,perc:o(e)})))):(l=b.length-1,o=n.labelFraction(m),f=b.map(((e,n)=>t.ingest({index:n,label:v(e,n,b),value:e,perc:n?o(e):0,perc2:n===l?1:o(b[n+1])})))),d.source=f,d.add=f,this.value=f,d}});const u=e=>e.source.x,c=e=>e.source.y,d=e=>e.target.x,f=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"}]},r.inherits(h,t.Transform,{transform(e,t){var n=e.sourceX||u,a=e.sourceY||c,i=e.targetX||d,o=e.targetY||f,l=e.as||"path",s=e.orient||"vertical",h=e.shape||"line",m=y.get(h+"-"+s)||y.get(h);return m||r.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),t.visit(t.SOURCE,(e=>{e[l]=m(n(e),a(e),i(e),o(e))})),t.reflow(e.modified()).modifies(l)}});const m=(e,t,n,r)=>"M"+e+","+t+"L"+n+","+r,g=(e,t,n,r)=>{var a=n-e,i=r-t,o=Math.sqrt(a*a+i*i)/2;return"M"+e+","+t+"A"+o+","+o+" "+180*Math.atan2(i,a)/Math.PI+" 0 1 "+n+","+r},p=(e,t,n,r)=>{const a=n-e,i=r-t,o=.2*(a+i),l=.2*(i-a);return"M"+e+","+t+"C"+(e+o)+","+(t+l)+" "+(n+l)+","+(r-o)+" "+n+","+r},y=r.fastmap({line:m,"line-radial":(e,t,n,r)=>m(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),arc:g,"arc-radial":(e,t,n,r)=>g(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),curve:p,"curve-radial":(e,t,n,r)=>p(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),"orthogonal-horizontal":(e,t,n,r)=>"M"+e+","+t+"V"+r+"H"+n,"orthogonal-vertical":(e,t,n,r)=>"M"+e+","+t+"H"+n+"V"+r,"orthogonal-radial":(e,t,n,r)=>{const a=Math.cos(e),i=Math.sin(e),o=Math.cos(n),l=Math.sin(n);return"M"+t*a+","+t*i+"A"+t+","+t+" 0 0,"+((Math.abs(n-e)>Math.PI?n<=e:n>e)?1:0)+" "+t*o+","+t*l+"L"+r*o+","+r*l},"diagonal-horizontal":(e,t,n,r)=>{const a=(e+n)/2;return"M"+e+","+t+"C"+a+","+t+" "+a+","+r+" "+n+","+r},"diagonal-vertical":(e,t,n,r)=>{const a=(t+r)/2;return"M"+e+","+t+"C"+e+","+a+" "+n+","+a+" "+n+","+r},"diagonal-radial":(e,t,n,r)=>{const a=Math.cos(e),i=Math.sin(e),o=Math.cos(n),l=Math.sin(n),s=(t+r)/2;return"M"+t*a+","+t*i+"C"+s*a+","+s*i+" "+s*o+","+s*l+" "+r*o+","+r*l}});function v(e,t,n){e=+e,t=+t,n=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((t-e)/n)),i=new Array(a);++r<a;)i[r]=e+r*n;return i}function b(e){t.Transform.call(this,null,e)}function M(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function w(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function x(){}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"]}]},r.inherits(b,t.Transform,{transform(e,t){var n,a,i,o=e.as||["startAngle","endAngle"],l=o[0],s=o[1],u=e.field||r.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,f=t.source,h=f.map(u),m=h.length,g=c,p=(d-c)/function(e,t){let n=0;if(void 0===t)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let a of e)(a=+t(a,++r,e))&&(n+=a)}return n}(h),y=v(m);for(e.sort&&y.sort(((e,t)=>h[e]-h[t])),n=0;n<m;++n)i=h[y[n]],(a=f[y[n]])[l]=g,a[s]=g+=i*p;return this.value=h,t.reflow(e.modified()).modifies(o)}});var k=.7,S=1/k,N="\\s*([+-]?\\d+)\\s*",D="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",A="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",O=/^#([0-9a-f]{3,8})$/,T=new RegExp("^rgb\\("+[N,N,N]+"\\)$"),E=new RegExp("^rgb\\("+[A,A,A]+"\\)$"),R=new RegExp("^rgba\\("+[N,N,N,D]+"\\)$"),C=new RegExp("^rgba\\("+[A,A,A,D]+"\\)$"),L=new RegExp("^hsl\\("+[D,A,A]+"\\)$"),q=new RegExp("^hsla\\("+[D,A,A,D]+"\\)$"),z={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function I(){return this.rgb().formatHex()}function P(){return this.rgb().formatRgb()}function F(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=O.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?_(t):3===n?new V(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?j(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?j(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=T.exec(e))?new V(t[1],t[2],t[3],1):(t=E.exec(e))?new V(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=R.exec(e))?j(t[1],t[2],t[3],t[4]):(t=C.exec(e))?j(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=L.exec(e))?X(t[1],t[2]/100,t[3]/100,1):(t=q.exec(e))?X(t[1],t[2]/100,t[3]/100,t[4]):z.hasOwnProperty(e)?_(z[e]):"transparent"===e?new V(NaN,NaN,NaN,0):null}function _(e){return new V(e>>16&255,e>>8&255,255&e,1)}function j(e,t,n,r){return r<=0&&(e=t=n=NaN),new V(e,t,n,r)}function H(e){return e instanceof x||(e=F(e)),e?new V((e=e.rgb()).r,e.g,e.b,e.opacity):new V}function U(e,t,n,r){return 1===arguments.length?H(e):new V(e,t,n,null==r?1:r)}function V(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function $(){return"#"+B(this.r)+B(this.g)+B(this.b)}function G(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function B(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function X(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Q(e,t,n,r)}function Y(e){if(e instanceof Q)return new Q(e.h,e.s,e.l,e.opacity);if(e instanceof x||(e=F(e)),!e)return new Q;if(e instanceof Q)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,l=i-a,s=(i+a)/2;return l?(o=t===i?(n-r)/l+6*(n<r):n===i?(r-t)/l+2:(t-n)/l+4,l/=s<.5?i+a:2-i-a,o*=60):l=s>0&&s<1?0:o,new Q(o,l,s,e.opacity)}function Q(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function J(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}M(x,F,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:I,formatHex:I,formatHsl:function(){return Y(this).formatHsl()},formatRgb:P,toString:P}),M(V,U,w(x,{brighter:function(e){return e=null==e?S:Math.pow(S,e),new V(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?k:Math.pow(k,e),new V(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$,formatHex:$,formatRgb:G,toString:G})),M(Q,(function(e,t,n,r){return 1===arguments.length?Y(e):new Q(e,t,n,null==r?1:r)}),w(x,{brighter:function(e){return e=null==e?S:Math.pow(S,e),new Q(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?k:Math.pow(k,e),new Q(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new V(J(e>=240?e-240:e+120,a,r),J(e,a,r),J(e<120?e+240:e-120,a,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));var W=e=>()=>e;function K(e){return 1==(e=+e)?Z:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):W(isNaN(t)?n:t)}}function Z(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):W(isNaN(e)?t:e)}var ee=function e(t){var n=K(t);function r(e,t){var r=n((e=U(e)).r,(t=U(t)).r),a=n(e.g,t.g),i=n(e.b,t.b),o=Z(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=a(t),e.b=i(t),e.opacity=o(t),e+""}}return r.gamma=e,r}(1);function te(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,a=t.slice();return function(i){for(n=0;n<r;++n)a[n]=e[n]*(1-i)+t[n]*i;return a}}function ne(e,t){var n,r=t?t.length:0,a=e?Math.min(r,e.length):0,i=new Array(a),o=new Array(r);for(n=0;n<a;++n)i[n]=ue(e[n],t[n]);for(;n<r;++n)o[n]=t[n];return function(e){for(n=0;n<a;++n)o[n]=i[n](e);return o}}function re(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ae(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ie(e,t){var n,r={},a={};for(n in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)n in e?r[n]=ue(e[n],t[n]):a[n]=t[n];return function(e){for(n in r)a[n]=r[n](e);return a}}var oe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,le=new RegExp(oe.source,"g");function se(e,t){var n,r,a,i=oe.lastIndex=le.lastIndex=0,o=-1,l=[],s=[];for(e+="",t+="";(n=oe.exec(e))&&(r=le.exec(t));)(a=r.index)>i&&(a=t.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(n=n[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,s.push({i:o,x:ae(n,r)})),i=le.lastIndex;return i<t.length&&(a=t.slice(i),l[o]?l[o]+=a:l[++o]=a),l.length<2?s[0]?function(e){return function(t){return e(t)+""}}(s[0].x):function(e){return function(){return e}}(t):(t=s.length,function(e){for(var n,r=0;r<t;++r)l[(n=s[r]).i]=n.x(e);return l.join("")})}function ue(e,t){var n,r,a=typeof t;return null==t||"boolean"===a?W(t):("number"===a?ae:"string"===a?(n=F(t))?(t=n,ee):se:t instanceof F?ee:t instanceof Date?re:(r=t,!ArrayBuffer.isView(r)||r instanceof DataView?Array.isArray(t)?ne:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?ie:ae:te))(e,t)}function ce(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function de(e){return n.isContinuous(e)&&e!==n.Sequential}const fe=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 he(e){t.Transform.call(this,null,e),this.modified(!0)}function me(e,t,a){n.isLogarithmic(e)&&(Math.abs(t.reduce(((e,t)=>e+(t<0?-1:t>0?1:0)),0))!==t.length&&a.warn("Log scale domain includes zero: "+r.stringValue(t)));return t}function ge(e,t,a){return r.isFunction(e)&&(t||a)?n.interpolateRange(e,pe(t||[0,1],a)):e}function pe(e,t){return t?e.slice().reverse():e}function ye(e){t.Transform.call(this,null,e)}r.inherits(he,t.Transform,{transform(e,t){var a=t.dataflow,i=this.value,o=function(e){var t,a=e.type,i="";if(a===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)&&(i=2===(t=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0)?n.Sequential+"-":3===t?n.Diverging+"-":"");return(i+a||n.Linear).toLowerCase()}(e);for(o in i&&o===i.type||(this.value=i=n.scale(o)()),e)if(!fe[o]){if("padding"===o&&de(i.type))continue;r.isFunction(i[o])?i[o](e[o]):a.warn("Unsupported scale property: "+o)}return function(e,t,a){var i=e.type,o=t.round||!1,l=t.range;if(null!=t.rangeStep)l=function(e,t,a){e!==n.Band&&e!==n.Point&&r.error("Only band and point scales support rangeStep.");var i=(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(a,o,i)]}(i,t,a);else if(t.scheme&&(l=function(e,t,a){var i,o,l=t.schemeExtent;r.isArray(t.scheme)?o=n.interpolateColors(t.scheme,t.interpolate,t.interpolateGamma):(i=t.scheme.toLowerCase(),(o=n.scheme(i))||r.error("Unrecognized scheme name: ".concat(t.scheme)));return a=e===n.Threshold?a+1:e===n.BinOrdinal?a-1:e===n.Quantile||e===n.Quantize?+t.schemeCount||5:a,n.isInterpolating(e)?ge(o,l,t.reverse):r.isFunction(o)?n.quantizeInterpolator(ge(o,l),a):e===n.Ordinal?o:o.slice(0,a)}(i,t,a),r.isFunction(l))){if(e.interpolator)return e.interpolator(l);r.error("Scale type ".concat(i," does not support interpolating color schemes."))}if(l&&n.isInterpolating(i))return e.interpolator(n.interpolateColors(pe(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?ce:ue);l&&e.range(pe(l,t.reverse))}(i,e,function(e,t,a){let i=t.bins;if(i&&!r.isArray(i)){const t=e.domain(),n=t[0],a=r.peek(t),o=i.step;let l=null==i.start?n:i.start,s=null==i.stop?a:i.stop;o||r.error("Scale bins parameter missing step property."),l<n&&(l=o*Math.ceil(n/o)),s>a&&(s=o*Math.floor(a/o)),i=v(l,s+o/2,o)}i?e.bins=i:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(i?t.domain||t.domainRaw||(e.domain(i),a=i.length):e.bins=e.domain());return a}(i,e,function(e,t,a){const i=function(e,t,n){return t?(e.domain(me(e.type,t,n)),t.length):-1}(e,t.domainRaw,a);if(i>-1)return i;var o,l,s=t.domain,u=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;de(u)&&t.padding&&s[0]!==r.peek(s)&&(s=function(e,t,a,i,o,l){var s=Math.abs(r.peek(a)-a[0]),u=s/(s-2*i),c=e===n.Log?r.zoomLog(t,null,u):e===n.Sqrt?r.zoomPow(t,null,u,.5):e===n.Pow?r.zoomPow(t,null,u,o||1):e===n.Symlog?r.zoomSymlog(t,null,u,l||1):r.zoomLinear(t,null,u);return(t=t.slice())[0]=c[0],t[t.length-1]=c[1],t}(u,s,t.range,t.padding,t.exponent,t.constant));if((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)){const e=(l=t.domainMid)>s[o]?o+1:l<s[0]?0:o;e!==o&&a.warn("Scale domainMid exceeds domain min or max.",l),s.splice(e,0,l)}e.domain(me(u,s,a)),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}(i,e,a))),t.fork(t.NO_SOURCE|t.NO_FIELDS)}}),r.inherits(ye,t.Transform,{transform(e,n){const r=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return r&&n.source.sort(t.stableCompare(e.sort)),this.modified(r),n}});const ve="zero",be="center",Me="normalize",we=["y0","y1"];function xe(e){t.Transform.call(this,null,e)}function ke(e,t,n,r,a){for(var i,o=(t-e.sum)/2,l=e.length,s=0;s<l;++s)(i=e[s])[r]=o,i[a]=o+=Math.abs(n(i))}function Se(e,t,n,r,a){for(var i,o=1/e.sum,l=0,s=e.length,u=0,c=0;u<s;++u)(i=e[u])[r]=l,i[a]=l=o*(c+=Math.abs(n(i)))}function Ne(e,t,n,r,a){for(var i,o,l=0,s=0,u=e.length,c=0;c<u;++c)(i=+n(o=e[c]))<0?(o[r]=s,o[a]=s+=i):(o[r]=l,o[a]=l+=i)}xe.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:ve,values:[ve,be,Me]},{name:"as",type:"string",array:!0,length:2,default:we}]},r.inherits(xe,t.Transform,{transform(e,n){var a,i,o,l,s=e.as||we,u=s[0],c=s[1],d=t.stableCompare(e.sort),f=e.field||r.one,h=e.offset===be?ke:e.offset===Me?Se:Ne;for(a=function(e,t,n,r){var a,i,o,l,s,u,c,d,f,h=[],m=e=>e(s);if(null==t)h.push(e.slice());else for(a={},i=0,o=e.length;i<o;++i)s=e[i],(c=a[u=t.map(m)])||(a[u]=c=[],h.push(c)),c.push(s);for(u=0,f=0,l=h.length;u<l;++u){for(i=0,d=0,o=(c=h[u]).length;i<o;++i)d+=Math.abs(r(c[i]));c.sum=d,d>f&&(f=d),n&&c.sort(n)}return h.max=f,h}(n.source,e.groupby,d,f),i=0,o=a.length,l=a.max;i<o;++i)h(a[i],l,f,u,c);return n.reflow(e.modified()).modifies(s)}}),e.axisticks=a,e.datajoin=i,e.encode=l,e.legendentries=s,e.linkpath=h,e.pie=b,e.scale=he,e.sortitems=ye,e.stack=xe,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=vega-encode.min.js.map