vega-parser
Advanced tools
Comparing version 1.0.0-beta.21 to 1.0.0-beta.22
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression"),require("vega-scenegraph"),require("d3-color"),require("d3-format"),require("d3-time-format"),require("vega-scale"),require("vega-dataflow")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression","vega-scenegraph","d3-color","d3-format","d3-time-format","vega-scale","vega-dataflow"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.d3,e.d3,e.vega,e.vega)}(this,function(e,t,n,a,r,i,o,l,u){"use strict";function s(e,n){t.error(e+' for "outer" push: '+t.stringValue(n))}function d(e){var t={};return function(n,a){var r=t[a]||(t[a]=e(a));return r(n)}}function f(e,t,n){return St.setMonth(e),St.setDate(t),kt(St,n)}function c(e){return f(e,1,"%B")}function p(e){return f(e,1,"%b")}function g(e){return f(0,2+e,"%A")}function h(e){return f(0,2+e,"%a")}function m(e){return 1+~~(new Date(e).getMonth()/3)}function v(e){return 1+~~(new Date(e).getUTCMonth()/3)}function y(e,t,n){try{e[t].apply(e,["EXPRESSION"].concat([].slice.call(n)))}catch(t){e.warn(t)}return n[n.length-1]}function b(){return y(this.context.dataflow,"warn",arguments)}function x(){return y(this.context.dataflow,"info",arguments)}function k(){return y(this.context.dataflow,"debug",arguments)}function S(){return"Math.sqrt(Math.pow(event.touches[0].clientX - event.touches[1].clientX, 2) + Math.pow(event.touches[0].clientY - event.touches[1].clientY, 2))"}function w(){return"Math.atan2(event.touches[1].clientY - event.touches[0].clientY,event.touches[1].clientX - event.touches[0].clientX)"}function R(e,t){var n=this.context.dataflow;Ot&&Ot.open?n.loader().sanitize(e,{context:"open",name:t}).then(function(e){Ot.open(e,t)}).catch(function(e){n.warn("Open url failed: "+e)}):n.warn("Open function can only be invoked in a browser.")}function O(){return Ot?Ot.screen:{}}function z(){return Ot?[Ot.innerWidth,Ot.innerHeight]:[void 0,void 0]}function $(e,n){var a=t.isString(e)?n.scales[e]:t.isObject(e)&&e.signal?n.signals[e.signal]:void 0;return a&&a.value}function E(e,t,a,r){if(t[0].type===$t){e=t[0].value;var i=Dt+e;if(!r.hasOwnProperty(i))try{r[i]=a.scaleRef(e)}catch(e){}}else t[0].type===Et&&(e=t[0].name,t[0]=new n.ASTNode($t),t[0].raw='{signal:"'+e+'"}')}function P(e,t){var n=$(e,(t||this).context);return n&&n.range?n.range():[0,0]}function D(e,t){var n=$(e,(t||this).context);return n?n.domain():[]}function F(e,t){var n=$(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0}function j(e,t,n){return l.bandSpace(e||0,t||0,n||0)}function M(e,t){var n=$(e,(t||this).context);return n?n.copy():void 0}function _(e,t,n){var a=$(e,(n||this).context);return a?a(t):void 0}function A(e,n,a){var r=$(e,(a||this).context);return r?t.isArray(n)?(r.invertRange||r.invert)(n):(r.invert||r.invertExtent)(n):void 0}function C(e){return function(t,n,a){var r=$(t,(a||this).context);return r&&r.path[e](n)}}function W(e){var t=this.context.data[e];return t?t.values.value:[]}function q(e,n,a,r){n[0].type!==$t&&t.error("First argument to tuples must be a string literal.");var i=n[0].value,o=Ft+i;r.hasOwnProperty(o)||(r[o]=a.getData(i).tuplesRef())}function L(e,t,n){var a=this.context.data[e]["index:"+t],r=a?a.value.get(n):void 0;return r?r.count:r}function V(e,n,a,r){n[0].type!==$t&&t.error("First argument to indata must be a string literal."),n[1].type!==$t&&t.error("Second argument to indata must be a string literal.");var i=n[0].value,o=n[1].value,l=Pt+o;r.hasOwnProperty(l)||(r[l]=a.getData(i).indataRef(a,o))}function U(e){return function(t){for(var n in e)if(t[n]!==e[n])return!1;return!0}}function B(e,n){for(var a=n.fields,r=n.values,i=n.getter||(n.getter=[]),o=a.length,l=0;l<o;++l)if(i[l]=i[l]||t.field(a[l]),i[l](e)!==r[l])return!1;return!0}function T(e,n){for(var a,r=n.intervals,i=r.length,o=0;o<i;++o)if(a=r[o].getter||(r[o].getter=t.field(r[o].field)),!At(a(e),r[o].extent))return!1;return!0}function N(e,t,n,a,r,i){for(var o,l,u=this.context.data[e],s=u?u.values.value:[],d=a!==qt,f=s.length,c=0;c<f;++c)if(o=s[c],l=t===o.unit,!(r===Vt&&l||r===Lt&&!l)&&(l=i(n,o),d^l))return l;return!f||d}function I(e,t,n,a,r){return N.call(this,e,t,n,a,r,B)}function J(e,t,n,a,r){return N.call(this,e,t,n,a,r,T)}function X(e,t,n){return 1===arguments.length?Ut[e]:(Ut[e]=t,n&&(It[e]=n),Yt&&(Yt.functions[e]=Nt+e),this)}function Y(e){var t=n.functions(e);Bt.forEach(function(e){t[e]=Tt+e});for(var a in Ut)t[a]=Nt+a;return t}function H(e){return nn.hasOwnProperty(e)}function G(e,t,n,a,r){for(var i,o=0,l=e.length;t<l;++t){if(i=e[t],!o&&i===n)return t;r&&r.indexOf(i)>=0?--o:a&&a.indexOf(i)>=0&&++o}return t}function K(e){for(var t=[],n=0,a=e.length,r=0;r<a;)r=G(e,r,fn,on+un,ln+sn),t.push(e.substring(n,r).trim()),n=++r;if(0===t.length)throw"Empty event selector: "+e;return t}function Q(e){return"["===e[0]?Z(e):ee(e)}function Z(e){var t,n,a=1,r=e.length,i=1;if(i=G(e,i,ln,on,ln),i===r)throw"Empty between selector: "+e;if(t=K(e.substring(a,i)),2!==t.length)throw"Between selector must have two elements: "+e;if(e=e.slice(i+1).trim(),e[0]!==pn)throw"Expected '>' after between selector: "+e;return t=t.map(Q),n=Q(e.slice(1).trim()),n.between?{between:t,stream:n}:(n.between=t,n)}function ee(e){var t,n,a={source:Jt},r=[],i=[0,0],o=0,l=0,u=e.length,s=0;if(e[u-1]===sn){if(s=e.lastIndexOf(un),!(s>=0))throw"Unmatched right brace: "+e;try{i=te(e.substring(s+1,u-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,s).trim(),u=e.length,s=0}if(!u)throw e;if(e[0]===cn&&(o=++s),t=G(e,s,dn),t<u&&(r.push(e.substring(l,t).trim()),l=s=++t),s=G(e,s,on),s===u)r.push(e.substring(l,u).trim());else if(r.push(e.substring(l,s).trim()),n=[],l=++s,l===u)throw"Unmatched left bracket: "+e;for(;s<u;){if(s=G(e,s,ln),s===u)throw"Unmatched left bracket: "+e;if(n.push(e.substring(l,s).trim()),s<u-1&&e[++s]!==on)throw"Expected left bracket: "+e;l=++s}if(!(u=r.length)||gn.test(r[u-1]))throw"Invalid event selector: "+e;return u>1?(a.type=r[1],o?a.markname=r[0].slice(1):H(r[0])?a.marktype=r[0]:a.source=r[0]):a.type=r[0],"!"===a.type.slice(-1)&&(a.consume=!0,a.type=a.type.slice(0,-1)),null!=n&&(a.filter=n),i[0]&&(a.throttle=i[0]),i[1]&&(a.debounce=i[1]),a}function te(e){var t=e.split(fn);if(!e.length||t.length>2)throw e;return t.map(function(t){var n=+t;if(n!==n)throw e;return n})}function ne(e){return e===mn?hn:e||hn}function ae(e,n){var a=e.merge?re:e.stream?ie:e.type?oe:t.error("Invalid stream specification: "+t.stringValue(e));return a(e,n)}function re(e,t){var n=e.merge.map(function(e){return ae(e,t)}),a=le({merge:n},e,t);return t.addStream(a).id}function ie(e,t){var n=ae(e.stream,t),a=le({stream:n},e,t);return t.addStream(a).id}function oe(e,t){var n=t.event(ne(e.source),e.type),a=le({stream:n},e,t);return 1===Object.keys(a).length?n:t.addStream(a).id}function le(e,n,a){var r=n.between;return r&&(2!==r.length&&t.error('Stream "between" parameter must have 2 entries: '+t.stringValue(n)),e.between=[ae(r[0],a),ae(r[1],a)]),r=n.filter?t.array(n.filter):[],(n.marktype||n.markname||n.markrole)&&r.push(ue(n.marktype,n.markname,n.markrole)),n.source===mn&&r.push("inScope(event.item)"),r.length&&(e.filter=Gt("("+r.join(")&&(")+")").$expr),null!=(r=n.throttle)&&(e.throttle=+r),null!=(r=n.debounce)&&(e.debounce=+r),n.consume&&(e.consume=!0),e}function ue(e,t,n){var a="event.item";return a+(e&&"*"!==e?"&&"+a+".mark.marktype==='"+e+"'":"")+(n?"&&"+a+".mark.role==='"+n+"'":"")+(t?"&&"+a+".mark.name==='"+t+"'":"")}function se(e,n){return t.isArray(e)?e.map(function(e){return se(e,n)}):t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported parameter object: "+JSON.stringify(e)):e}function de(e,n,a,r){var i,o,l;if(e.signal)i="datum",l=On(e.signal,n,a,r);else if(e.group||e.parent){for(o=Math.max(1,e.level||1),i="item";o-- >0;)i+=".mark.group";e.parent?(l=e.parent,i+=".datum"):l=e.group}else e.datum?(i="datum",l=e.datum):t.error("Invalid field reference: "+JSON.stringify(e));return e.signal||(t.isString(l)?(r[l]=1,l=t.splitAccessPath(l).map(t.stringValue).join("][")):l=de(l,n,a,r)),i+"["+l+"]"}function fe(e,n){if(!t.isString(e))return-1;var a=n.scaleType(e);return"band"===a||"point"===a?1:0}function ce(e,n,a,r){var i;if(t.isString(e))i=Dt+e,a.hasOwnProperty(i)||(a[i]=n.scaleRef(e)),i=t.stringValue(i);else{for(i in n.scales)a[Dt+i]=n.scaleRef(i);i=t.stringValue(Dt)+"+"+zn(e,n,a,r)}return"_["+i+"]"}function pe(e,n,a,r){var i,o,l,u={},s="var o=item,datum=o.datum,$;";for(i in e)o=e[i],t.isArray(o)?s+=jn(i,o,r,a,u):(l=Dn(i,o,r,a,u),s+=Fn("o",i,l));return s+=wn(e,n),s+="return 1;",{$expr:s,$fields:Object.keys(u),$output:Object.keys(e)}}function ge(e){return t.isObject(e)?e:{value:e}}function he(e,n,a){for(var r in n)a&&a.hasOwnProperty(r)||(e[r]=t.extend(e[r]||{},n[r]));return e}function me(e,t,n,a,r){var i,o;r=r||{},r.encoders={$encode:i={}},e=ve(e,t,n,a.config);for(o in e)i[o]=pe(e[o],t,r,a);return r}function ve(e,n,a,r){var i,o,l;if(r=r&&(a===_n?r.group:a===Mn?r.mark&&r.mark[n]:null)){i={};for(o in r)l=ye(o,e)||("fill"===o||"stroke"===o)&&(ye("fill",e)||ye("stroke",e)),l||(i[o]={value:r[o]});e=t.extend({},e),e.enter=t.extend(i,e.enter)}return e}function ye(e,t){return t.enter&&t.enter[e]||t.update&&t.update[e]}function be(e,t,n,a){this.id=-1,this.type=e,this.value=t,this.params=n,a&&(this.parent=a)}function xe(e,t,n,a){return new be(e,t,n,a)}function ke(e,t){return xe("Operator",e,t)}function Se(e){var t={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(t),t}function we(e,t){return t?{$field:e,$name:t}:{$field:e}}function Re(e,t){return{$compare:e,$order:t}}function Oe(e){return{$key:e}}function ze(e){return t.isObject(e)?(e.order===ba?"-":"+")+$e(e.op,e.field):""}function $e(e,t){return(e&&e.signal?"$"+e.signal:e||"")+(e&&t?"_":"")+(t&&t.signal?"$"+t.signal:t||"")}function Ee(e){return e&&e.signal}function Pe(e){return function(t,n,a){return xe(e,n,t||void 0,a)}}function De(e,t,n){var a,r,i,o={};for(r=0,i=e.params.length;r<i;++r)a=e.params[r],o[a.name]=Fe(a,t,n);return o}function Fe(e,n,a){var r,i=e.type;return"index"===i?Me(e,n,a):"param"===i?_e(e,n,a):"projection"===i?a.projectionRef(n[e.name]):(r=n[e.name],void 0===r?void(e.required&&t.error("Missing required "+n.type+" parameter: "+e.name)):e.array&&!Ee(r)?r.map(function(t){return je(e,t,a)}):je(e,r,a))}function je(e,n,a){var r=e.type;if(Ee(n))return Le(r)?t.error("Expression references can not be signals."):Ve(r)?a.fieldRef(n):Ue(r)?a.compareRef(n):a.signalRef(n.signal);var i=e.expr||Ve(r);return i&&Ce(n)?Gt(n.expr,a):i&&We(n)?we(n.field):Le(r)?Gt(n,a):qe(r)?Se(a.getData(n).values):Ve(r)?we(n):Ue(r)?Re(t.array(n.field),t.array(n.order)):n}function Me(e,n,a){return t.isString(n.from)||t.error('Lookup "from" parameter must be a string literal.'),a.getData(n.from).lookupRef(a,n.key)}function _e(e,n,a){var r=n[e.name];return e.array?(t.isArray(r)||t.error("Expected an array of sub-parameters. Instead: "+r),r.map(function(t){return Ae(e,t,a)})):Ae(e,r,a)}function Ae(e,n,a){var r,i,o,l,u;for(l=0,u=e.params.length;l<u;++l){i=e.params[l];for(o in i.key)if(i.key[o]!==n[o]){i=null;break}if(i)break}return i||t.error("Unsupported parameter: "+JSON.stringify(n)),r=t.extend(De(i,n,a),i.key),Se(a.add(_a(r)))}function Ce(e){return e&&e.expr}function We(e){return e&&e.field}function qe(e){return"data"===e}function Le(e){return"expr"===e}function Ve(e){return"field"===e}function Ue(e){return"compare"===e}function Be(e,t,n,a,r){this.scope=e,this.input=t,this.output=n,this.values=a,this.aggregate=r,this.index={}}function Te(e){return t.isString(e)?e:null}function Ne(e,t,n){var a,r=$e(n.op,n.field);if(t.ops){for(var i=0,o=t.as.length;i<o;++i)if(t.as[i]===r)return}else t.ops=["count"],t.fields=[null],t.as=["count"];n.op&&(t.ops.push((a=n.op.signal)?e.signalRef(a):n.op),t.fields.push(e.fieldRef(n.field)),t.as.push(r))}function Ie(e,t,n,a,r,i,o){var l,u,s=t[n]||(t[n]={}),d=ze(i),f=Te(r);if(null!=f&&(e=t.scope,f+=d?"|"+d:"",l=s[f]),!l){var c=i?{field:va,pulse:t.countsRef(e,r,i)}:{field:e.fieldRef(r),pulse:Se(t.output)};d&&(c.sort=e.sortRef(i)),u=e.add(xe(a,void 0,c)),o&&(t.index[r]=u),l=Se(u),null!=f&&(s[f]=l)}return l}function Je(e,t){return null!=e?e:t}function Xe(e,t,n){var a,r=+t.symbolSize;return a=n&&n.update&&n.update.fontSize,a||(a=n&&n.enter&&n.enter.fontSize),a&&(a=a.value),a||(a=+t.labelFontSize),e.size?{$expr:"Math.max(Math.ceil(Math.sqrt(_.scale(datum))),"+a+")"}:Math.max(Math.ceil(Math.sqrt(r)),a)}function Ye(e){return er.hasOwnProperty(e)}function He(e){return"quantile"===e}function Ge(e,n){return t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported object: "+t.stringValue(e)):e}function Ke(e){t.error("Can not find data set: "+e)}function Qe(e,n,a){return e?e.signal?a.signalRef(e.signal):(t.isArray(e)?Ze:e.fields?tt:et)(e,n,a):void(null==n.domainMin&&null==n.domainMax||t.error("No scale domain defined for domainMin/domainMax to override."))}function Ze(e,t,n){return e.map(function(e){return Ge(e,n)})}function et(e,t,n){var a=n.getData(e.data);return a||Ke(e.data),Ye(t.type)?a.valuesRef(n,e.field,at(e.sort,!1)):He(t.type)?a.domainRef(n,e.field):a.extentRef(n,e.field)}function tt(e,n,a){var r=e.data,i=e.fields.reduce(function(e,n){return e.push(t.isString(n)?{data:r,field:n}:n),e},[]);return(Ye(n.type)?nt:He(n.type)?rt:it)(e,a,i)}function nt(e,t,n){var a,r,i,o;return a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.countsRef(t,e.field)}),r=t.add(xa({groupby:va,ops:["sum"],fields:[t.fieldRef("count")],as:["count"],pulse:a})),i=t.add(wa({pulse:Se(r)})),o=t.add(Ta({field:va,sort:t.sortRef(at(e.sort,!0)),pulse:Se(i)})),Se(o)}function at(e,n){return e&&(e.field||e.op?e.field||"count"===e.op?n&&e.field?t.error("Multiple domain scales can not sort by field."):n&&e.op&&"count"!==e.op&&t.error("Multiple domain scales support op count only."):t.error("No field provided for sort aggregate op: "+e.op):t.isObject(e)?e.field="key":e={field:"key"}),e}function rt(e,t,n){var a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.domainRef(t,e.field)});return Se(t.add(Ma({values:a})))}function it(e,t,n){var a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.extentRef(t,e.field)});return Se(t.add(ja({extents:a})))}function ot(e,n){var a=e.range,r=n.config.range;if(a.signal)return n.signalRef(a.signal);if(t.isString(a))r&&r.hasOwnProperty(a)?a=r[a]:"width"===a?a=[0,{signal:"width"}]:"height"===a?a=Ye(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:t.error("Unrecognized scale range value: "+a);else{if(Ye(e.type)&&!t.isArray(a))return Qe(a,e,n);t.isArray(a)||t.error("Unsupported range type: "+a)}return a.map(function(e){return Ge(e,n)})}function lt(e,t){var n=[];e.transform&&e.transform.forEach(function(e){n.push(Na(e,t))}),e.on&&e.on.forEach(function(n){Ha(n,t,e.name)}),t.addDataPipeline(e.name,ut(e,t,n))}function ut(e,t,n){var a,r,i,o,l,u=[],s=null,d=!1,f=!1;for(e.values?u.push(s=st({$ingest:e.values,$format:e.format})):e.url?u.push(s=st({$request:e.url,$format:e.format})):e.source&&(a=t.getData(e.source),s=a.output,u.push(null)),r=0,i=n.length;r<i;++r)o=n[r],l=o.metadata,s||l.source||u.push(s=st()),u.push(o),l.generates&&(f=!0),l.modifies&&!f&&(d=!0),l.source?s=o:l.changes&&(s=null);return a&&(u[0]=qa({derive:d,pulse:Se(a.output)}),d&&u.splice(1,0,st())),s||u.push(st()),u.push(Ua({})),u}function st(e){var t=wa({},e);return t.metadata={source:!0},t}function dt(e,t){return{scale:e.scale,range:t}}function ft(e,n){var a,r,i,o,l;return n.background=e.background||n.config.background,l=Se(n.root=n.add(ke())),n.addSignal("width",e.width||-1),n.addSignal("height",e.height||-1),n.addSignal("padding",ht(e.padding)),t.array(e.signals).forEach(function(e){dr[e.name]||yt(e,n)}),r=n.add(wa()),i=he({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e.encode),i=n.add(za(me(i,Kt,_n,n,{pulse:Se(r)}))),o=n.add(Ba({legendMargin:n.config.legendMargin,autosize:e.autosize||n.config.autosize,mark:l,pulse:Se(i)})),n.pushState(Se(i),Se(o)),sr(e,n,!0),a=n.add(Sa({mark:l,pulse:Se(o)})),a=n.add(La({pulse:Se(a)})),a=n.add(Ua({pulse:Se(a)})),n.addData("root",new Be(n,r,r,a)),n}function ct(e){this.config=e,this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.background=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._markpath=[]}function pt(e){this.config=e.config,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._markpath=e._markpath}function gt(){return{autosize:"pad",background:null,group:null,mark:{arc:{fill:"steelblue"},area:{fill:"steelblue"},image:null,line:{stroke:"steelblue"},path:{stroke:"steelblue"},rect:{fill:"steelblue"},rule:{stroke:"#000"},shape:{stroke:"steelblue"},symbol:{fill:"steelblue",size:64},text:{fill:"#000",font:"sans-serif",fontSize:11}},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domainDefault:!0,domainWidth:1,domainColor:"#000",gridDefault:!1,gridWidth:1,gridColor:"#ddd",gridDash:[],gridOpacity:1,labelDefault:!0,labelColor:"#000",labelFont:"sans-serif",labelFontSize:10,labelPadding:2,tickDefault:!0,tickRound:!0,tickSize:5,tickWidth:1,tickColor:"#000",titleAlign:"center",titlePadding:2,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold"},legend:{orient:"right",offset:18,padding:0,entryPadding:5,titlePadding:5,gradientWidth:100,gradientHeight:20,gradientStrokeColor:"#ddd",gradientStrokeWidth:0,gradientLabelBaseline:"top",gradientLabelOffset:2,labelColor:"#000",labelFontSize:10,labelFont:"sans-serif",labelAlign:"left",labelBaseline:"middle",labelOffset:8,symbolType:"circle",symbolSize:100,symbolColor:"#888",symbolStrokeWidth:1.5,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold",titleAlign:"left",titleBaseline:"top"},range:{category:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}var ht=function(e){return t.isObject(e)?e:t.isNumber(e)?{top:e,bottom:e,left:e,right:e}:{top:0,left:0,bottom:0,right:0}},mt="outer",vt=["value","update","react","bind"],yt=function(e,n){var a=e.name;if(e.push===mt)n.signals[a]||s("No prior signal definition",a),vt.forEach(function(n){void 0!==e[n]&&t.error("Invalid property",n)});else{var r=n.addSignal(a,e.value);e.react===!1&&(r.react=!1),e.bind&&n.addBinding(a,e.bind)}},bt=d(i.format),xt=d(o.utcFormat),kt=d(o.timeFormat),St=new Date(2e3,0,1),wt=function(e){var t=this.context.group,n=!1;if(t)for(;e;){if(e===t){n=!0;break}e=e.mark.group}return n},Rt=function(e,t,n){var a,r=e[0],i=e[1];return i<r&&(a=i,i=r,r=a),a=i-r,a>=n-t?[t,n]:[Math.min(Math.max(r,t),n-a),Math.min(Math.max(i,a),n)]},Ot="undefined"!=typeof window&&window||null,zt=function(e){return e[e.length-1]-e[0]},$t="Literal",Et="Identifier",Pt="@",Dt="%",Ft=":",jt=C("area"),Mt=C("bounds"),_t=C("centroid"),At=function(e,t){var n,a=t[0],r=t[t.length-1];return a>r&&(n=a,a=r,r=n),a<=e&&e<=r},Ct=function(e,t,n){if(e){var a=this.context.dataflow,r=e.mark.source;a.pulse(r,a.changeset().encode(e,t))}return void 0!==n?n:e},Wt=function(e,n,a,r,i,o){var l,u,s=this.context.dataflow,d=this.context.data[e],f=d.input,c=d.changes,p=s.stamp();if(!(f.value.length||n||r))return 0;if((!c||c.stamp<p)&&(d.changes=c=s.changeset(),c.stamp=p,s.runAfter(function(){s.pulse(f,c).run()})),a&&(l=a===!0?t.truthy:t.isArray(a)||null!=a._id?a:U(a),c.remove(l)),n&&c.insert(n),r&&(l=U(r),f.value.filter(l).length?c.remove(l):c.insert(r)),i)for(u in o)c.modify(i,u,o[u]);return 1},qt="union",Lt="unit",Vt="others",Ut={pad:t.pad,truncate:t.truncate,rgb:r.rgb,lab:r.lab,hcl:r.hcl,hsl:r.hsl,format:bt,utcFormat:xt,timeFormat:kt,monthFormat:c,monthAbbrevFormat:p,dayFormat:g,dayAbbrevFormat:h,quarter:m,utcquarter:v,warn:b,info:x,debug:k,inScope:wt,clampRange:Rt,pinchDistance:S,pinchAngle:w,open:R,screen:O,windowsize:z,span:zt,bandspace:j,inrange:At,encode:Ct,modify:Wt,vlPoint:I,vlInterval:J},Bt=["view","item","group","xy","x","y"],Tt="event.vega.",Nt="this.",It={};X("bandwidth",F,E),X("copy",M,E),X("domain",D,E),X("range",P,E),X("invert",A,E),X("scale",_,E),X("gradient",a.scaleGradient,E),X("geoArea",jt,E),X("geoBounds",Mt,E),X("geoCentroid",_t,E),X("indata",L,V),X("tuples",W,q);var Jt,Xt={blacklist:["_"],whitelist:["datum","event"],fieldvar:"datum",globalvar:function(e){return"_["+t.stringValue("$"+e)+"]"},functions:Y,constants:n.constants,visitors:It},Yt=n.codegen(Xt),Ht="$",Gt=function(e,a,r){var i,o,l={};try{i=n.parse(e)}catch(n){t.error("Expression parse error: "+t.stringValue(e))}return i.visit(function(e){if("CallExpression"===e.type){var t=e.callee.name,n=Xt.visitors[t];n&&n(t,e.arguments,a,l)}}),o=Yt(i),o.globals.forEach(function(e){var t=Ht+e;!l.hasOwnProperty(t)&&a.getSignal(e)&&(l[t]=a.signalRef(e))}),{$expr:r?r+"return("+o.code+");":o.code,$fields:o.fields,$params:l}},Kt="group",Qt="rect",Zt="rule",en="symbol",tn="text",nn=t.toSet(["*","arc","area","group","image","line","path","rect","rule","shape","symbol","text"]),an=function(e,t){return Jt=t||rn,K(e.trim()).map(Q)},rn="view",on="[",ln="]",un="{",sn="}",dn=":",fn=",",cn="@",pn=">",gn=/[\[\]\{\}]/,hn="view",mn="scope",vn=function(e,t){return e.signal?t.getSignal(e.signal).id:ae(e,t)},yn="var datum=event.item&&event.item.datum;",bn=function(e,n,a){var r,i=e.events,o=e.update,l=e.encode,u=[],s="";i||t.error("Signal update missing events specification."),t.isString(i)&&(i=an(i)),i=t.array(i).filter(function(e){return e.signal?(u.push(e),0):1}),i.length&&u.push(i.length>1?{merge:i}:i[0]),null!=l&&(o&&t.error("Signal encode and update are mutually exclusive."),o="encode(item(),"+t.stringValue(l)+")"),s=t.isString(o)?Gt(o,n,yn):null!=o.expr?Gt(o.expr,n,yn):null!=o.value?o.value:null!=o.signal?{$expr:"_.value",$params:{value:n.signalRef(o.signal)}}:t.error("Invalid signal update specification."),r={target:a,update:s},e.force&&(r.options={force:!0}),u.forEach(function(e){e={source:vn(e,n)},n.addUpdate(t.extend(e,r))})},xn=function(e,t){var n=t.getSignal(e.name);if(e.update){var a=Gt(e.update,t);n.update=a.$expr,n.params=a.$params}e.on&&e.on.forEach(function(e){bn(e,t,n.id)})},kn=function(e,t){var n={};for(var a in e)"name"!==a&&(n[a]=se(e[a],t));t.addProjection(e.name,n)},Sn=t.toSet(["rule"]),wn=function(e,t){var n="";return Sn[t]?n:(e.x2&&(e.x?(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;",n+="o.width=o.x2-o.x;"):n+=e.width?"o.x=o.x2-o.width;":"o.x=o.x2;"),e.xc&&(n+=e.width?"o.x=o.xc-o.width/2;":"o.x=o.xc;"),e.y2&&(e.y?(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;",n+="o.height=o.y2-o.y;"):n+=e.height?"o.y=o.y2-o.height;":"o.y=o.y2;"),e.yc&&(n+=e.height?"o.y=o.yc-o.height/2;":"o.y=o.yc;"),n)},Rn=function(e,t,n,a){function r(e,r,i,o){var l=Dn(null,r,t,n,a),u=Dn(null,i,t,n,a),s=Dn(null,o,t,n,a);return"this."+e+"("+[l,u,s].join(",")+").toString()"}return e.c?r("hcl",e.h,e.c,e.l):e.h||e.s?r("hsl",e.h,e.s,e.l):e.l||e.a?r("lab",e.l,e.a,e.b):e.r||e.g||e.b?r("rgb",e.r,e.g,e.b):null},On=function(e,n,a,r){var i=Gt(e,n);return i.$fields.forEach(function(e){r[e]=1}),t.extend(a,i.$params),i.$expr},zn=function(e,n,a,r){return de(t.isObject(e)?e:{datum:e},n,a,r)},$n=function(e,t,n,a,r){var i,o,l,u=ce(e.scale,n,a,r);return null!=e.range?(i=+e.range,o=u+".range()",t=0===i?o+"[0]":"($="+o+","+(1===i?"$[$.length-1]":"$[0]+"+i+"*($[$.length-1]-$[0])")+")"):(t=null!=t?u+"("+t+")":null,e.band&&(l=fe(e.scale,n))&&(o=u+".bandwidth",i=+e.band,i=o+"()"+(1===i?"":"*"+i),l<0&&(i="("+o+"?"+i+":0)"),t=(t?t+"+":"")+i,e.extra&&(t="(datum.extra?"+u+"(datum.extra.value):"+t+")")),null==t&&(t="0")),t},En=function(e,n,a,r){return"this.gradient("+ce(e.gradient,n,a,r)+","+t.stringValue(e.start)+","+t.stringValue(e.stop)+","+t.stringValue(e.count)+")"},Pn=function(e,n,a,r){return t.isObject(e)?"("+Dn(null,e,n,a,r)+")":e},Dn=function(e,n,a,r,i){if(null!=n.gradient)return En(n,a,r,i);var o=null!=n.color?Rn(n.color,a,r,i):null!=n.field?zn(n.field,a,r,i):null!=n.signal?On(n.signal,a,r,i):null!=n.value?t.stringValue(n.value):null;return null!=n.scale&&(o=$n(n,o,a,r,i)),null!=n.exponent&&(o="Math.pow("+o+","+Pn(n.exponent,a,r,i)+")"),null!=n.mult&&(o+="*"+Pn(n.mult,a,r,i)),null!=n.offset&&(o+="+"+Pn(n.offset,a,r,i)),n.round&&(o="Math.round("+o+")"),o},Fn=function(e,n,a){return e+"["+t.stringValue(n)+"]="+a+";"},jn=function(e,t,n,a,r){var i="";return t.forEach(function(t){var o=Dn(e,t,n,a,r);i+=t.test?On(t.test,n,a,r)+"?"+o+":":o}),Fn("o",e,i)},Mn="mark",_n="frame",An="scope",Cn="axis",Wn="axis-domain",qn="axis-grid",Ln="axis-label",Vn="axis-tick",Un="axis-title",Bn="legend",Tn="legend-entry",Nn="legend-gradient",In="legend-label",Jn="legend-symbol",Xn="legend-title",Yn={name:1,interactive:1},Hn=function(e,t,n,a,r,i){return{type:e,name:i?i.name:void 0,role:t,key:n,from:a,interactive:!(!i||!i.interactive),encode:he(r,i,Yn)}},Gn=function(e,t,n){var a={value:0},r={};return r.enter={opacity:a,x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},stroke:{value:t.gradientStrokeColor},strokeWidth:{value:t.gradientStrokeWidth}},r.exit={opacity:a},r.update={x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},fill:{gradient:e},opacity:{value:1}},Hn(Qt,Nn,void 0,void 0,r,n)},Kn="top",Qn="left",Zn="right",ea="bottom",ta="index",na="label",aa="offset",ra="perc",ia="size",oa="total",la="value",ua="datum."+ra+'<=0?"left":datum.'+ra+'>=1?"right":"center"',sa=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,text:{field:na},fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},baseline:{value:t.gradientLabelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:ra,mult:t.gradientWidth},r.y=i.y={value:t.gradientHeight,offset:t.gradientLabelOffset},r.align=i.align={signal:ua},Hn(tn,In,na,a,l,n)},da=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,fill:{value:t.labelColor},text:{field:na},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},align:{value:t.labelAlign},baseline:{value:t.labelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:aa,offset:t.labelOffset},r.y=i.y={field:ia,mult:.5,offset:{field:oa,offset:{field:{group:"entryPadding"},mult:{field:ta}}}},Hn(tn,In,na,a,l,n)},fa=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,shape:{value:t.symbolType},size:{value:t.symbolSize},strokeWidth:{value:t.symbolStrokeWidth}},e.fill||(r.stroke={value:t.symbolColor}),l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:aa,mult:.5},r.y=i.y={field:ia,mult:.5,offset:{field:oa,offset:{field:{group:"entryPadding"},mult:{field:ta}}}},["shape","size","fill","stroke","opacity"].forEach(function(t){e[t]&&(i[t]=r[t]={scale:e[t],field:la})}),Hn(en,Jn,na,a,l,n)},ca=function(e,t,n,a){var r={value:0},i={};return i.enter={x:{field:{group:"padding"}},y:{field:{group:"padding"}},opacity:r,fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign},baseline:{value:t.titleBaseline}},i.exit={opacity:r},i.update={opacity:{value:1},text:{field:"title"}},Hn(tn,Xn,null,a,i,n)},pa=function(e,t,n,a,r,i){return{type:Kt,name:t,role:e,from:n,interactive:a,encode:r,marks:i}},ga=function(e){return e.role||(e.type===Kt&&(e.legends||e.axes)?An:Mn)},ha=function(e){return{clip:e.clip||!1,interactive:e.interactive!==!1,marktype:e.type,name:e.name||void 0,role:ga(e),zindex:+e.zindex||void 0}},ma=function(e){return e},va=we("key"),ya="ascending",ba="descending",xa=Pe("Aggregate"),ka=Pe("AxisTicks"),Sa=Pe("Bound"),wa=Pe("Collect"),Ra=Pe("Compare"),Oa=Pe("DataJoin"),za=Pe("Encode"),$a=Pe("Facet"),Ea=Pe("Field"),Pa=Pe("Key"),Da=Pe("LegendEntries"),Fa=Pe("Mark"),ja=Pe("MultiExtent"),Ma=Pe("MultiValues"),_a=Pe("Params"),Aa=Pe("PreFacet"),Ca=Pe("Projection"),Wa=Pe("Proxy"),qa=Pe("Relay"),La=Pe("Render"),Va=Pe("Scale"),Ua=Pe("Sieve"),Ba=Pe("ViewLayout"),Ta=Pe("Values"),Na=function(e,n){var a=u.definition(e.type);a||t.error("Unrecognized transform type: "+e.type);var r=xe(a.type,null,De(a,e,n));return e.signal&&n.addSignal(e.signal,n.proxy(r)),r.metadata=a.metadata||{},r},Ia=function(e,n,a){var r,i,o,l,u;return e?(r=e.facet)&&(n||t.error("Only group marks can be faceted."),null!=r.field?l=u=Se(a.getData(r.data).output):(i=a.keyRef(r.groupby),e.data?u=a.getData(e.data).aggregate:(o=Na(t.extend({type:"aggregate",groupby:t.array(r.groupby)},r.aggregate)),o.params.key=i,o.params.pulse=Se(a.getData(r.data).output),l=u=Se(a.add(o))))):l=Se(a.add(wa(null,[{}]))),l||(l=e.$ref?e:Se(e.mark?a.getData(ma(e.mark)).output:a.getData(e.data).output)),{key:i,pulse:l,parent:u}};Be.fromEntries=function(e,t){var n=t.length,a=1,r=t[0],i=t[n-1],o=t[n-2],l=null;for(e.add(t[0]);a<n;++a)t[a].params.pulse=Se(t[a-1]),e.add(t[a]),"Aggregate"===t[a].type&&(l=t[a]);return new Be(e,r,o,i,l)};var Ja=Be.prototype;Ja.countsRef=function(e,t,n){var a,r,i,o=this,l=o.counts||(o.counts={}),u=Te(t);return null!=u&&(e=o.scope,a=l[u]),a?n&&n.field&&Ne(e,a.agg.params,n):(i={groupby:e.fieldRef(t,"key"),pulse:Se(o.output)},n&&n.field&&Ne(e,i,n),r=e.add(xa(i)),a=e.add(wa({pulse:Se(r)})),a={agg:r,ref:Se(a)},null!=u&&(l[u]=a)),a.ref},Ja.tuplesRef=function(){return Se(this.values)},Ja.extentRef=function(e,t){return Ie(e,this,"extent","Extent",t,!1)},Ja.domainRef=function(e,t){return Ie(e,this,"domain","Values",t,!1)},Ja.valuesRef=function(e,t,n){return Ie(e,this,"vals","Values",t,n||!0)},Ja.lookupRef=function(e,t){return Ie(e,this,"lookup","TupleIndex",t,!1)},Ja.indataRef=function(e,t){return Ie(e,this,"indata","TupleIndex",t,!0,!0)};var Xa=function(e,n,a){var r,i,o,l,u=e.from.facet,s=u.name,d=Se(n.getData(u.data).output);u.name||t.error("Facet must have a name: "+JSON.stringify(u)),u.data||t.error("Facet must reference a data set: "+JSON.stringify(u)),u.field?l=n.add(Aa({field:n.fieldRef(u.field),pulse:d})):u.groupby?l=n.add($a({key:n.keyRef(u.groupby),group:n.proxy(a.parent),pulse:d})):t.error("Facet must specify groupby or field: "+JSON.stringify(u)),r=n.fork(),i=r.add(wa()),o=r.add(Ua({pulse:Se(i)})),r.addData(s,new Be(r,i,i,o)),r.addSignal("parent",null),l.params.subflow={$subflow:sr(e,r).toRuntime()}},Ya=function(e,t,n){var a=t.add(Aa({pulse:n.pulse})),r=t.fork();r.add(Ua()),r.addSignal("parent",null),a.params.subflow={$subflow:sr(e,r).toRuntime()}},Ha=function(e,t,n){var a,r,i=e.remove,o=e.insert,l=e.toggle,u=e.modify,s=e.values,d=t.add(ke());a="if("+e.trigger+',modify("'+n+'",'+[o,i,l,u,s].map(function(e){return null==e?"null":e}).join(",")+"),0)",r=Gt(a,t),d.update=r.$expr,d.params=r.$params},Ga=function(e,n){var a,r,i,o,l,u,s,d,f,c,p=ga(e),g=e.type===Kt,h=e.from&&e.from.facet,m=p===An||p===_n;r=Ia(e.from,g,n),a=n.add(Oa({key:r.key,pulse:r.pulse,clean:!g})),a=i=n.add(wa({pulse:Se(a)})),a=n.add(Fa({markdef:ha(e),scenepath:{$itempath:n.markpath()},pulse:Se(a)})),d=Se(a),a=n.add(za(me(e.encode,e.type,p,n,{pulse:d}))),a.params.parent=n.encode(),e.transform&&e.transform.forEach(function(e){var r=Na(e,n);(r.metadata.generates||r.metadata.changes)&&t.error("Mark transforms should not generate new data."),r.params.pulse=Se(a),n.add(a=r)}),f=Se(a),(h||m)&&(a=n.add(Ba({legendMargin:n.config.legendMargin,mark:d,pulse:f})),n.operators.pop(),n.pushState(f,Se(a)),h?Xa(e,n,r):Ya(e,n,r),n.popState(),n.operators.push(a)),o=n.add(Sa({mark:d,pulse:Se(a)})),c=Se(o),!g||h||m||(n.pushState(f,c),p===Mn?Ya(e,n,r):sr(e,n),n.popState()),l=n.add(La({pulse:c})),u=n.add(Ua({pulse:c},void 0,n.parent())),null!=e.name&&(s=ma(e.name),n.addData(s,new Be(n,i,l,u)),e.on&&e.on.forEach(function(e){(e.insert||e.remove||e.toggle)&&t.error("Marks only support modify triggers."), | ||
Ha(e,n,s)}))},Ka=function(e,n){var a,r,i,o,l,u,s,d,f=e.type||"symbol",c=n.config.legend,p=e.name||void 0,g=e.encode||{},h=!!e.interactive,m=e.size||e.shape||e.fill||e.stroke||e.opacity;return m||t.error("Missing valid scale for legend."),a={orient:Je(e.orient,c.orient),title:e.title},r=Se(n.add(wa(null,[a]))),u=he({update:{offset:ge(Je(e.offset,c.offset)),padding:ge(Je(e.padding,c.padding)),titlePadding:ge(Je(e.titlePadding,c.titlePadding))}},g.legend),s={update:{x:{field:{group:"padding"}},y:{field:{group:"padding"}},entryPadding:ge(Je(e.entryPadding,c.entryPadding))}},"gradient"===f?(i=Se(n.add(Da({type:"gradient",scale:n.scaleRef(m),count:n.property(e.tickCount),values:n.property(e.values),formatSpecifier:n.property(e.format)}))),d=[Gn(m,c,g.gradient),sa(e,c,g.labels,i)]):(i=Se(n.add(Da({size:Xe(e,c,g.labels),scale:n.scaleRef(m),count:n.property(e.tickCount),values:n.property(e.values),formatSpecifier:n.property(e.formatSpecifier)}))),d=[fa(e,c,g.symbols,i),da(e,c,g.labels,i)]),d=[pa(Tn,null,r,h,s,d)],a.title&&(l=ca(e,c,g.title,r),s.update.y.offset={field:{group:"titlePadding"},offset:l.encode.update.fontSize||l.encode.enter.fontSize},d.push(l)),o=pa(Bn,p,r,h,u,d),e.zindex&&(o.zindex=e.zindex),Ga(o,n)},Qa=["identity","ordinal","band","point","index","linear","pow","sqrt","log","sequential","time","utc","quantize","quantile","threshold"],Za=t.toSet(Qa),er=t.toSet(Qa.slice(1,5)),tr=function(e,n){var a,r,i=e.type||"linear";Za.hasOwnProperty(i)||t.error("Unrecognized scale type: "+i),a={type:i,domain:Qe(e.domain,e,n)},null!=e.range&&(null!=e.rangeStep&&t.error("Scale range and rangeStep are mutually exclusive."),a.range=ot(e,n));for(r in e)a[r]||"name"===r||(a[r]=Ge(e[r],n));n.addScale(e.name,a)},nr=function(e,n){var a=n.config,r=e.orient,i=r===Kn||r===ea?a.axisX:a.axisY,o=a["axis"+r[0].toUpperCase()+r.slice(1)],l="band"===n.scaleType(e.scale)&&a.axisBand;return i||o||l?t.extend({},a.axis,i,o,l):a.axis},ar=function(e,t,n,a){var r,i,o,l,u,s=e.orient,d={value:0},f={};return f.enter=r={opacity:d,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},f.exit={opacity:d},f.update=i={opacity:{value:1}},s===Kn||s===ea?(o="x",u="y"):(o="y",u="x"),l=o+"2",r[u]=d,i[o]=r[o]=dt(e,0),i[l]=r[l]=dt(e,1),Hn(Zt,Wn,null,a,f,n)},rr=function(e,t,n,a){var r,i,o,l,u,s,d,f,c=e.orient,p=e.gridScale,g=c===Qn||c===Kn?1:-1,h=g*e.offset||0,m={value:0},v={};return v.enter=r={opacity:m,stroke:{value:t.gridColor},strokeWidth:{value:t.gridWidth},strokeDash:{value:t.gridDash}},v.exit=i={opacity:m},v.update=o={opacity:{value:t.gridOpacity}},l={scale:e.scale,field:la,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},c===Kn||c===ea?(u="x",s="y",f="height"):(u="y",s="x",f="width"),d=s+"2",o[u]=r[u]=i[u]=l,p?(r[s]={scale:p,range:0,mult:g,offset:h},o[d]=r[d]={scale:p,range:1,mult:g,offset:h}):(r[s]={value:h},o[d]=r[d]={signal:f,mult:g,offset:h}),Hn(Zt,qn,la,a,v,n)},ir=function(e,t,n,a,r){var i,o,l,u,s,d=e.orient,f=d===Qn||d===Kn?-1:1,c={value:0},p={};return p.enter=i={opacity:c,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},p.exit=o={opacity:c},p.update=l={opacity:{value:1}},u=ge(r),u.mult=f,s={scale:e.scale,field:la,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},d===Kn||d===ea?(l.y=i.y=c,l.y2=i.y2=u,l.x=i.x=o.x=s):(l.x=i.x=c,l.x2=i.x2=u,l.y=i.y=o.y=s),Hn(Zt,Vn,na,a,p,n)},or=function(e,t,n,a,r){var i,o,l,u,s,d=e.orient,f=d===Qn||d===Kn?-1:1,c=null!=e.labelPadding?e.labelPadding:t.labelPadding,p={value:0},g={};return g.enter=i={opacity:p,fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},text:{field:na}},g.exit=o={opacity:p},g.update=l={opacity:{value:1}},u=ge(r),u.mult=f,u.offset=ge(c),u.offset.mult=f,s={scale:e.scale,field:la,band:.5},d===Kn||d===ea?(l.y=i.y=u,l.x=i.x=o.x=s,l.align={value:"center"},l.baseline={value:d===Kn?"bottom":"top"}):(l.x=i.x=u,l.y=i.y=o.y=s,l.align={value:d===Zn?"left":"right"},l.baseline={value:"middle"}),Hn(tn,Ln,na,a,g,n)},lr=function(e,t,n,a){var r,i,o=e.orient,l=o===Qn||o===Kn?-1:1,u=o===Kn||o===ea,s={};return s.enter={opacity:{value:0},fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign}},s.exit={opacity:{value:0}},s.update=r={opacity:{value:1},text:{field:"title"}},i={scale:e.scale,range:.5},u?(r.x=i,r.angle={value:0},r.baseline={value:o===Kn?"bottom":"top"}):(r.y=i,r.angle={value:90*l},r.baseline={value:"bottom"}),null!=t.titleAngle&&(r.angle={value:t.titleAngle}),null!=t.titleBaseline&&(r.baseline={value:t.titleBaseline}),null!=t.titleX?r.x={value:t.titleX}:u&&!ye(n,"x")&&(s.enter.auto={value:!0}),null!=t.titleY?r.y={value:t.titleY}:u||ye(n,"y")||(s.enter.auto={value:!0}),Hn(tn,Un,null,a,s,n)},ur=function(e,t){var n,a,r,i,o,l,u,s=nr(e,t),d=e.name||void 0,f=e.encode||{},c=!!e.interactive;return n={orient:e.orient,tick:null!=e.tick?!!e.tick:s.tickDefault,label:null!=e.label?!!e.label:s.labelDefault,grid:null!=e.grid?!!e.grid:s.gridDefault,domain:null!=e.domain?!!e.domain:s.domainDefault,title:e.title},a=Se(t.add(wa({},[n]))),l=he({update:{range:{expr:'abs(span(range("'+e.scale+'")))'},offset:ge(e.offset||0),position:ge(e.position||0),titlePadding:ge(e.titlePadding||s.titlePadding),minExtent:ge(e.minExtent||s.minExtent),maxExtent:ge(e.maxExtent||s.maxExtent)}},f.axis),r=Se(t.add(ka({scale:t.scaleRef(e.scale),extra:s.tickExtra,count:t.property(e.tickCount),values:t.property(e.values),formatSpecifier:t.property(e.format)}))),u=[],n.grid&&u.push(rr(e,s,f.grid,r)),n.tick&&(i=null!=e.tickSize?e.tickSize:s.tickSize,u.push(ir(e,s,f.ticks,r,i))),n.label&&(i=n.tick?i:0,u.push(or(e,s,f.labels,r,i))),n.domain&&u.push(ar(e,s,f.domain,a)),n.title&&u.push(lr(e,s,f.title,a)),o=pa(Cn,d,a,c,l,u),e.zindex&&(o.zindex=e.zindex),Ga(o,t)},sr=function(e,n,a){var r=t.array(e.signals);return a||r.forEach(function(e){yt(e,n)}),t.array(e.projections).forEach(function(e){kn(e,n)}),t.array(e.data).forEach(function(e){lt(e,n)}),t.array(e.scales).forEach(function(e){tr(e,n)}),r.forEach(function(e){xn(e,n)}),n.parseLambdas(),t.array(e.axes).forEach(function(e){ur(e,n)}),t.array(e.marks).forEach(function(e){Ga(e,n)}),t.array(e.legends).forEach(function(e){Ka(e,n)}),n},dr=t.toSet(["width","height","padding"]),fr=ct.prototype=pt.prototype;fr.fork=function(){return new pt(this)},fr.toRuntime=function(){return this.finish(),{background:this.background,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings}},fr.id=function(){return(this._subid?this._subid+":":0)+this._id++},fr.add=function(e){return this.operators.push(e),e.id=this.id(),e.refs&&(e.refs.forEach(function(t){t.$ref=e.id}),e.refs=null),e},fr.proxy=function(e){var t=e instanceof be?Se(e):e;return this.add(Wa({value:t}))},fr.addStream=function(e){return this.streams.push(e),e.id=this.id(),e},fr.addUpdate=function(e){return this.updates.push(e),e},fr.finish=function(){function e(e,t,n){var a,r;e&&(a=e.data||(e.data={}),r=a[t]||(a[t]=[]),r.push(n))}var t,n;this.root&&(this.root.root=!0);for(t in this.signals)this.signals[t].signal=t;for(t in this.scales)this.scales[t].scale=t;for(t in this.data){n=this.data[t],e(n.input,t,"input"),e(n.output,t,"output"),e(n.values,t,"values");for(var a in n.index)e(n.index[a],t,"index:"+a)}return this},fr.pushState=function(e,t){this._encode.push(Se(this.add(Ua({pulse:e})))),this._parent.push(t),this._markpath.push(-1)},fr.popState=function(){this._parent.pop(),this._encode.pop(),this._markpath.pop()},fr.parent=function(){return t.peek(this._parent)},fr.encode=function(){return t.peek(this._encode)},fr.markpath=function(){var e=this._markpath;return++e[e.length-1],e.slice()},fr.fieldRef=function(e,n){if(t.isString(e))return we(e,n);e.signal||t.error("Unsupported field reference: "+JSON.stringify(e));var a,r=e.signal,i=this.field[r];return i||(a={name:this.signalRef(r)},n&&(a.as=n),this.field[r]=i=Se(this.add(Ea(a)))),i},fr.compareRef=function(e){function n(e){return Ee(e)?(r=!0,Se(a[e.signal])):e}var a=this.signals,r=!1,i=t.array(e.field).map(n),o=t.array(e.order).map(n);return r?Se(this.add(Ra({fields:i,orders:o}))):Re(i,o)},fr.keyRef=function(e){function n(e){return Ee(e)?(r=!0,Se(a[e.signal])):e}var a=this.signals,r=!1;return e=t.array(e).map(n),r?Se(this.add(Pa({fields:e}))):Oe(e)},fr.sortRef=function(e){if(!e)return e;var t=[$e(e.op,e.field),"_id"],n=e.order||ya;return n.signal?Se(this.add(Ra({fields:t,orders:[n=this.signalRef(n.signal),n]}))):Re(t,[n,n])},fr.event=function(e,t){var n=e+":"+t;if(!this.events[n]){var a=this.id();this.streams.push({id:a,source:e,type:t}),this.events[n]=a}return this.events[n]},fr.addSignal=function(e,n){this.signals.hasOwnProperty(e)&&t.error("Duplicate signal name: "+e);var a=n instanceof be?n:this.add(ke(n));return this.signals[e]=a},fr.getSignal=function(e){return this.signals[e]||t.error("Unrecognized signal name: "+e),this.signals[e]},fr.signalRef=function(e){return this.signals[e]?Se(this.signals[e]):(this.lambdas[e]||(this.lambdas[e]=this.add(ke(null))),Se(this.lambdas[e]))},fr.parseLambdas=function(){for(var e=Object.keys(this.lambdas),t=0,n=e.length;t<n;++t){var a=e[t],r=Gt(a,this),i=this.lambdas[a];i.params=r.$params,i.update=r.$expr}},fr.property=function(e){return e&&e.signal?this.signalRef(e.signal):e},fr.addBinding=function(e,n){this.bindings||t.error("Nested signals do not support binding: "+e),this.bindings.push(t.extend({signal:e},n))},fr.addScaleProj=function(e,n){this.scales.hasOwnProperty(e)&&t.error("Duplicate scale or projection name: "+e),this.scales[e]=this.add(n)},fr.addScale=function(e,t){this.addScaleProj(e,Va(t))},fr.addProjection=function(e,t){this.addScaleProj(e,Ca(t))},fr.getScale=function(e){return this.scales[e]||t.error("Unrecognized scale name: "+e),this.scales[e]},fr.projectionRef=fr.scaleRef=function(e){return Se(this.getScale(e))},fr.projectionType=fr.scaleType=function(e){return this.getScale(e).params.type},fr.addData=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.data[e]=n},fr.getData=function(e){return this.data[e]||t.error("Undefined data set name: "+e),this.data[e]},fr.addDataPipeline=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.addData(e,Be.fromEntries(this,n))};var cr=function(e){var n,a=gt();for(n in e)a[n]=t.isObject(a[n])?t.extend(a[n],e[n]):a[n]=e[n];return a},pr=function(e,t){return ft(e,new ct(cr(t||e.config))).toRuntime()};e.parse=pr,e.selector=an,e.signal=yt,e.signalUpdates=xn,e.stream=vn,e.codeGenerator=Yt,e.functionContext=Ut,e.expressionFunction=X,e.MarkRole=Mn,e.FrameRole=_n,e.ScopeRole=An,e.AxisRole=Cn,e.AxisDomainRole=Wn,e.AxisGridRole=qn,e.AxisLabelRole=Ln,e.AxisTickRole=Vn,e.AxisTitleRole=Un,e.LegendRole=Bn,e.LegendEntryRole=Tn,e.LegendLabelRole=In,e.LegendSymbolRole=Jn,e.LegendTitleRole=Xn,e.marktypes=nn,e.isMarkType=H,e.Scope=ct,e.DataScope=Be,e.formatLocale=i.formatDefaultLocale,e.timeFormatLocale=o.timeFormatDefaultLocale,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression"),require("vega-scenegraph"),require("d3-color"),require("d3-format"),require("d3-time-format"),require("vega-scale"),require("vega-dataflow")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression","vega-scenegraph","d3-color","d3-format","d3-time-format","vega-scale","vega-dataflow"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.d3,e.d3,e.vega,e.vega)}(this,function(e,t,n,a,r,i,o,l,u){"use strict";function s(e,n){t.error(e+' for "outer" push: '+t.stringValue(n))}function d(e){var t={};return function(n,a){var r=t[a]||(t[a]=e(a));return r(n)}}function f(e,t,n){return St.setMonth(e),St.setDate(t),kt(St,n)}function c(e){return f(e,1,"%B")}function p(e){return f(e,1,"%b")}function g(e){return f(0,2+e,"%A")}function h(e){return f(0,2+e,"%a")}function m(e){return 1+~~(new Date(e).getMonth()/3)}function v(e){return 1+~~(new Date(e).getUTCMonth()/3)}function y(e,t,n){try{e[t].apply(e,["EXPRESSION"].concat([].slice.call(n)))}catch(t){e.warn(t)}return n[n.length-1]}function b(){return y(this.context.dataflow,"warn",arguments)}function x(){return y(this.context.dataflow,"info",arguments)}function k(){return y(this.context.dataflow,"debug",arguments)}function S(){return"Math.sqrt(Math.pow(event.touches[0].clientX - event.touches[1].clientX, 2) + Math.pow(event.touches[0].clientY - event.touches[1].clientY, 2))"}function w(){return"Math.atan2(event.touches[1].clientY - event.touches[0].clientY,event.touches[1].clientX - event.touches[0].clientX)"}function R(e,t){var n=this.context.dataflow;Ot&&Ot.open?n.loader().sanitize(e,{context:"open",name:t}).then(function(e){Ot.open(e,t)}).catch(function(e){n.warn("Open url failed: "+e)}):n.warn("Open function can only be invoked in a browser.")}function O(){return Ot?Ot.screen:{}}function z(){return Ot?[Ot.innerWidth,Ot.innerHeight]:[void 0,void 0]}function $(e,n){var a=t.isString(e)?n.scales[e]:t.isObject(e)&&e.signal?n.signals[e.signal]:void 0;return a&&a.value}function E(e,t,a,r){if(t[0].type===$t){e=t[0].value;var i=Dt+e;if(!r.hasOwnProperty(i))try{r[i]=a.scaleRef(e)}catch(e){}}else t[0].type===Et&&(e=t[0].name,t[0]=new n.ASTNode($t),t[0].raw='{signal:"'+e+'"}')}function P(e,t){var n=$(e,(t||this).context);return n&&n.range?n.range():[0,0]}function D(e,t){var n=$(e,(t||this).context);return n?n.domain():[]}function F(e,t){var n=$(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0}function _(e,t,n){return l.bandSpace(e||0,t||0,n||0)}function j(e,t){var n=$(e,(t||this).context);return n?n.copy():void 0}function M(e,t,n){var a=$(e,(n||this).context);return a?a(t):void 0}function A(e,n,a){var r=$(e,(a||this).context);return r?t.isArray(n)?(r.invertRange||r.invert)(n):(r.invert||r.invertExtent)(n):void 0}function C(e){return function(t,n,a){var r=$(t,(a||this).context);return r&&r.path[e](n)}}function W(e){var t=this.context.data[e];return t?t.values.value:[]}function q(e,n,a,r){n[0].type!==$t&&t.error("First argument to data functions must be a string literal.");var i=n[0].value,o=Ft+i;r.hasOwnProperty(o)||(r[o]=a.getData(i).tuplesRef())}function L(e,t,n){var a=this.context.data[e]["index:"+t],r=a?a.value.get(n):void 0;return r?r.count:r}function V(e,n,a,r){n[0].type!==$t&&t.error("First argument to indata must be a string literal."),n[1].type!==$t&&t.error("Second argument to indata must be a string literal.");var i=n[0].value,o=n[1].value,l=Pt+o;r.hasOwnProperty(l)||(r[l]=a.getData(i).indataRef(a,o))}function U(e){return function(t){for(var n in e)if("_id"!==n&&t[n]!==e[n])return!1;return!0}}function B(e,n){for(var a=n.fields,r=n.values,i=n.getter||(n.getter=[]),o=a.length,l=0;l<o;++l)if(i[l]=i[l]||t.field(a[l]),i[l](e)!==r[l])return!1;return!0}function T(e,n){for(var a,r=n.intervals,i=r.length,o=0;o<i;++o)if(a=r[o].getter||(r[o].getter=t.field(r[o].field)),!At(a(e),r[o].extent))return!1;return!0}function N(e,t,n,a,r,i){for(var o,l,u=this.context.data[e],s=u?u.values.value:[],d=a!==qt,f=s.length,c=0;c<f;++c)if(o=s[c],l=t===o.unit,!(r===Vt&&l||r===Lt&&!l)&&(l=i(n,o),d^l))return l;return!f||d}function I(e,t,n,a,r){return N.call(this,e,t,n,a,r,B)}function J(e,t,n,a,r){return N.call(this,e,t,n,a,r,T)}function X(e,t,n){return 1===arguments.length?Ut[e]:(Ut[e]=t,n&&(It[e]=n),Yt&&(Yt.functions[e]=Nt+e),this)}function Y(e){var t=n.functions(e);Bt.forEach(function(e){t[e]=Tt+e});for(var a in Ut)t[a]=Nt+a;return t}function H(e){return nn.hasOwnProperty(e)}function G(e,t,n,a,r){for(var i,o=0,l=e.length;t<l;++t){if(i=e[t],!o&&i===n)return t;r&&r.indexOf(i)>=0?--o:a&&a.indexOf(i)>=0&&++o}return t}function K(e){for(var t=[],n=0,a=e.length,r=0;r<a;)r=G(e,r,fn,on+un,ln+sn),t.push(e.substring(n,r).trim()),n=++r;if(0===t.length)throw"Empty event selector: "+e;return t}function Q(e){return"["===e[0]?Z(e):ee(e)}function Z(e){var t,n,a=1,r=e.length,i=1;if(i=G(e,i,ln,on,ln),i===r)throw"Empty between selector: "+e;if(t=K(e.substring(a,i)),2!==t.length)throw"Between selector must have two elements: "+e;if(e=e.slice(i+1).trim(),e[0]!==pn)throw"Expected '>' after between selector: "+e;return t=t.map(Q),n=Q(e.slice(1).trim()),n.between?{between:t,stream:n}:(n.between=t,n)}function ee(e){var t,n,a={source:Jt},r=[],i=[0,0],o=0,l=0,u=e.length,s=0;if(e[u-1]===sn){if(s=e.lastIndexOf(un),!(s>=0))throw"Unmatched right brace: "+e;try{i=te(e.substring(s+1,u-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,s).trim(),u=e.length,s=0}if(!u)throw e;if(e[0]===cn&&(o=++s),t=G(e,s,dn),t<u&&(r.push(e.substring(l,t).trim()),l=s=++t),s=G(e,s,on),s===u)r.push(e.substring(l,u).trim());else if(r.push(e.substring(l,s).trim()),n=[],l=++s,l===u)throw"Unmatched left bracket: "+e;for(;s<u;){if(s=G(e,s,ln),s===u)throw"Unmatched left bracket: "+e;if(n.push(e.substring(l,s).trim()),s<u-1&&e[++s]!==on)throw"Expected left bracket: "+e;l=++s}if(!(u=r.length)||gn.test(r[u-1]))throw"Invalid event selector: "+e;return u>1?(a.type=r[1],o?a.markname=r[0].slice(1):H(r[0])?a.marktype=r[0]:a.source=r[0]):a.type=r[0],"!"===a.type.slice(-1)&&(a.consume=!0,a.type=a.type.slice(0,-1)),null!=n&&(a.filter=n),i[0]&&(a.throttle=i[0]),i[1]&&(a.debounce=i[1]),a}function te(e){var t=e.split(fn);if(!e.length||t.length>2)throw e;return t.map(function(t){var n=+t;if(n!==n)throw e;return n})}function ne(e){return e===mn?hn:e||hn}function ae(e,n){var a=e.merge?re:e.stream?ie:e.type?oe:t.error("Invalid stream specification: "+t.stringValue(e));return a(e,n)}function re(e,t){var n=e.merge.map(function(e){return ae(e,t)}),a=le({merge:n},e,t);return t.addStream(a).id}function ie(e,t){var n=ae(e.stream,t),a=le({stream:n},e,t);return t.addStream(a).id}function oe(e,t){var n=t.event(ne(e.source),e.type),a=le({stream:n},e,t);return 1===Object.keys(a).length?n:t.addStream(a).id}function le(e,n,a){var r=n.between;return r&&(2!==r.length&&t.error('Stream "between" parameter must have 2 entries: '+t.stringValue(n)),e.between=[ae(r[0],a),ae(r[1],a)]),r=n.filter?t.array(n.filter):[],(n.marktype||n.markname||n.markrole)&&r.push(ue(n.marktype,n.markname,n.markrole)),n.source===mn&&r.push("inScope(event.item)"),r.length&&(e.filter=Gt("("+r.join(")&&(")+")").$expr),null!=(r=n.throttle)&&(e.throttle=+r),null!=(r=n.debounce)&&(e.debounce=+r),n.consume&&(e.consume=!0),e}function ue(e,t,n){var a="event.item";return a+(e&&"*"!==e?"&&"+a+".mark.marktype==='"+e+"'":"")+(n?"&&"+a+".mark.role==='"+n+"'":"")+(t?"&&"+a+".mark.name==='"+t+"'":"")}function se(e,n){return t.isArray(e)?e.map(function(e){return se(e,n)}):t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported parameter object: "+JSON.stringify(e)):e}function de(e,n,a,r){var i,o,l;if(e.signal)i="datum",l=On(e.signal,n,a,r);else if(e.group||e.parent){for(o=Math.max(1,e.level||1),i="item";o-- >0;)i+=".mark.group";e.parent?(l=e.parent,i+=".datum"):l=e.group}else e.datum?(i="datum",l=e.datum):t.error("Invalid field reference: "+JSON.stringify(e));return e.signal||(t.isString(l)?(r[l]=1,l=t.splitAccessPath(l).map(t.stringValue).join("][")):l=de(l,n,a,r)),i+"["+l+"]"}function fe(e,n){if(!t.isString(e))return-1;var a=n.scaleType(e);return"band"===a||"point"===a?1:0}function ce(e,n,a,r){var i;if(t.isString(e))i=Dt+e,a.hasOwnProperty(i)||(a[i]=n.scaleRef(e)),i=t.stringValue(i);else{for(i in n.scales)a[Dt+i]=n.scaleRef(i);i=t.stringValue(Dt)+"+"+zn(e,n,a,r)}return"_["+i+"]"}function pe(e,n,a,r){var i,o,l,u={},s="var o=item,datum=o.datum,$;";for(i in e)o=e[i],t.isArray(o)?s+=_n(i,o,r,a,u):(l=Dn(i,o,r,a,u),s+=Fn("o",i,l));return s+=wn(e,n),s+="return 1;",{$expr:s,$fields:Object.keys(u),$output:Object.keys(e)}}function ge(e){return t.isObject(e)?e:{value:e}}function he(e,n,a){for(var r in n)a&&a.hasOwnProperty(r)||(e[r]=t.extend(e[r]||{},n[r]));return e}function me(e,t,n,a,r){var i,o;r=r||{},r.encoders={$encode:i={}},e=ve(e,t,n,a.config);for(o in e)i[o]=pe(e[o],t,r,a);return r}function ve(e,n,a,r){var i,o,l;if(r=r&&(a===Mn?r.group:a===jn?r.mark&&r.mark[n]:null)){i={};for(o in r)l=ye(o,e)||("fill"===o||"stroke"===o)&&(ye("fill",e)||ye("stroke",e)),l||(i[o]={value:r[o]});e=t.extend({},e),e.enter=t.extend(i,e.enter)}return e}function ye(e,t){return t.enter&&t.enter[e]||t.update&&t.update[e]}function be(e,t,n,a){this.id=-1,this.type=e,this.value=t,this.params=n,a&&(this.parent=a)}function xe(e,t,n,a){return new be(e,t,n,a)}function ke(e,t){return xe("Operator",e,t)}function Se(e){var t={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(t),t}function we(e,t){return t?{$field:e,$name:t}:{$field:e}}function Re(e,t){return{$compare:e,$order:t}}function Oe(e){return{$key:e}}function ze(e){return t.isObject(e)?(e.order===ba?"-":"+")+$e(e.op,e.field):""}function $e(e,t){return(e&&e.signal?"$"+e.signal:e||"")+(e&&t?"_":"")+(t&&t.signal?"$"+t.signal:t||"")}function Ee(e){return e&&e.signal}function Pe(e){return function(t,n,a){return xe(e,n,t||void 0,a)}}function De(e,t,n){var a,r,i,o={};for(r=0,i=e.params.length;r<i;++r)a=e.params[r],o[a.name]=Fe(a,t,n);return o}function Fe(e,n,a){var r,i=e.type;return"index"===i?je(e,n,a):"param"===i?Me(e,n,a):"projection"===i?a.projectionRef(n[e.name]):(r=n[e.name],void 0===r?void(e.required&&t.error("Missing required "+n.type+" parameter: "+e.name)):e.array&&!Ee(r)?r.map(function(t){return _e(e,t,a)}):_e(e,r,a))}function _e(e,n,a){var r=e.type;if(Ee(n))return Le(r)?t.error("Expression references can not be signals."):Ve(r)?a.fieldRef(n):Ue(r)?a.compareRef(n):a.signalRef(n.signal);var i=e.expr||Ve(r);return i&&Ce(n)?Gt(n.expr,a):i&&We(n)?we(n.field):Le(r)?Gt(n,a):qe(r)?Se(a.getData(n).values):Ve(r)?we(n):Ue(r)?Re(t.array(n.field),t.array(n.order)):n}function je(e,n,a){return t.isString(n.from)||t.error('Lookup "from" parameter must be a string literal.'),a.getData(n.from).lookupRef(a,n.key)}function Me(e,n,a){var r=n[e.name];return e.array?(t.isArray(r)||t.error("Expected an array of sub-parameters. Instead: "+r),r.map(function(t){return Ae(e,t,a)})):Ae(e,r,a)}function Ae(e,n,a){var r,i,o,l,u;for(l=0,u=e.params.length;l<u;++l){i=e.params[l];for(o in i.key)if(i.key[o]!==n[o]){i=null;break}if(i)break}return i||t.error("Unsupported parameter: "+JSON.stringify(n)),r=t.extend(De(i,n,a),i.key),Se(a.add(Ma(r)))}function Ce(e){return e&&e.expr}function We(e){return e&&e.field}function qe(e){return"data"===e}function Le(e){return"expr"===e}function Ve(e){return"field"===e}function Ue(e){return"compare"===e}function Be(e,t,n,a,r){this.scope=e,this.input=t,this.output=n,this.values=a,this.aggregate=r,this.index={}}function Te(e){return t.isString(e)?e:null}function Ne(e,t,n){var a,r=$e(n.op,n.field);if(t.ops){for(var i=0,o=t.as.length;i<o;++i)if(t.as[i]===r)return}else t.ops=["count"],t.fields=[null],t.as=["count"];n.op&&(t.ops.push((a=n.op.signal)?e.signalRef(a):n.op),t.fields.push(e.fieldRef(n.field)),t.as.push(r))}function Ie(e,t,n,a,r,i,o){var l,u,s=t[n]||(t[n]={}),d=ze(i),f=Te(r);if(null!=f&&(e=t.scope,f+=d?"|"+d:"",l=s[f]),!l){var c=i?{field:va,pulse:t.countsRef(e,r,i)}:{field:e.fieldRef(r),pulse:Se(t.output)};d&&(c.sort=e.sortRef(i)),u=e.add(xe(a,void 0,c)),o&&(t.index[r]=u),l=Se(u),null!=f&&(s[f]=l)}return l}function Je(e,t){return null!=e?e:t}function Xe(e,t,n){var a,r=+t.symbolSize;return a=n&&n.update&&n.update.fontSize,a||(a=n&&n.enter&&n.enter.fontSize),a&&(a=a.value),a||(a=+t.labelFontSize),e.size?{$expr:"Math.max(Math.ceil(Math.sqrt(_.scale(datum))),"+a+")"}:Math.max(Math.ceil(Math.sqrt(r)),a)}function Ye(e){return er.hasOwnProperty(e)}function He(e){return"quantile"===e}function Ge(e,n){return t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported object: "+t.stringValue(e)):e}function Ke(e){t.error("Can not find data set: "+e)}function Qe(e,n,a){return e?e.signal?a.signalRef(e.signal):(t.isArray(e)?Ze:e.fields?tt:et)(e,n,a):void(null==n.domainMin&&null==n.domainMax||t.error("No scale domain defined for domainMin/domainMax to override."))}function Ze(e,t,n){return e.map(function(e){return Ge(e,n)})}function et(e,t,n){var a=n.getData(e.data);return a||Ke(e.data),Ye(t.type)?a.valuesRef(n,e.field,at(e.sort,!1)):He(t.type)?a.domainRef(n,e.field):a.extentRef(n,e.field)}function tt(e,n,a){var r=e.data,i=e.fields.reduce(function(e,n){return e.push(t.isString(n)?{data:r,field:n}:n),e},[]);return(Ye(n.type)?nt:He(n.type)?rt:it)(e,a,i)}function nt(e,t,n){var a,r,i,o;return a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.countsRef(t,e.field)}),r=t.add(xa({groupby:va,ops:["sum"],fields:[t.fieldRef("count")],as:["count"],pulse:a})),i=t.add(wa({pulse:Se(r)})),o=t.add(Ta({field:va,sort:t.sortRef(at(e.sort,!0)),pulse:Se(i)})),Se(o)}function at(e,n){return e&&(e.field||e.op?e.field||"count"===e.op?n&&e.field?t.error("Multiple domain scales can not sort by field."):n&&e.op&&"count"!==e.op&&t.error("Multiple domain scales support op count only."):t.error("No field provided for sort aggregate op: "+e.op):t.isObject(e)?e.field="key":e={field:"key"}),e}function rt(e,t,n){var a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.domainRef(t,e.field)});return Se(t.add(ja({values:a})))}function it(e,t,n){var a=n.map(function(e){var n=t.getData(e.data);return n||Ke(e.data),n.extentRef(t,e.field)});return Se(t.add(_a({extents:a})))}function ot(e,n){var a=e.range,r=n.config.range;if(a.signal)return n.signalRef(a.signal);if(t.isString(a))r&&r.hasOwnProperty(a)?a=r[a]:"width"===a?a=[0,{signal:"width"}]:"height"===a?a=Ye(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:t.error("Unrecognized scale range value: "+a);else{if(Ye(e.type)&&!t.isArray(a))return Qe(a,e,n);t.isArray(a)||t.error("Unsupported range type: "+a)}return a.map(function(e){return Ge(e,n)})}function lt(e,t){var n=[];e.transform&&e.transform.forEach(function(e){n.push(Na(e,t))}),e.on&&e.on.forEach(function(n){Ha(n,t,e.name)}),t.addDataPipeline(e.name,ut(e,t,n))}function ut(e,t,n){var a,r,i,o,l,u=[],s=null,d=!1,f=!1;for(e.values?u.push(s=st({$ingest:e.values,$format:e.format})):e.url?u.push(s=st({$request:e.url,$format:e.format})):e.source&&(a=t.getData(e.source),s=a.output,u.push(null)),r=0,i=n.length;r<i;++r)o=n[r],l=o.metadata,s||l.source||u.push(s=st()),u.push(o),l.generates&&(f=!0),l.modifies&&!f&&(d=!0),l.source?s=o:l.changes&&(s=null);return a&&(u[0]=qa({derive:d,pulse:Se(a.output)}),d&&u.splice(1,0,st())),s||u.push(st()),u.push(Ua({})),u}function st(e){var t=wa({},e);return t.metadata={source:!0},t}function dt(e,t){return{scale:e.scale,range:t}}function ft(e,n){var a,r,i,o,l;return n.background=e.background||n.config.background,l=Se(n.root=n.add(ke())),n.addSignal("width",e.width||-1),n.addSignal("height",e.height||-1),n.addSignal("padding",ht(e.padding)),t.array(e.signals).forEach(function(e){dr[e.name]||yt(e,n)}),r=n.add(wa()),i=he({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e.encode),i=n.add(za(me(i,Kt,Mn,n,{pulse:Se(r)}))),o=n.add(Ba({legendMargin:n.config.legendMargin,autosize:e.autosize||n.config.autosize,mark:l,pulse:Se(i)})),n.pushState(Se(i),Se(o)),sr(e,n,!0),a=n.add(Sa({mark:l,pulse:Se(o)})),a=n.add(La({pulse:Se(a)})),a=n.add(Ua({pulse:Se(a)})),n.addData("root",new Be(n,r,r,a)),n}function ct(e){this.config=e,this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.background=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._markpath=[]}function pt(e){this.config=e.config,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._markpath=e._markpath}function gt(){return{autosize:"pad",background:null,group:null,mark:{arc:{fill:"steelblue"},area:{fill:"steelblue"},image:null,line:{stroke:"steelblue"},path:{stroke:"steelblue"},rect:{fill:"steelblue"},rule:{stroke:"#000"},shape:{stroke:"steelblue"},symbol:{fill:"steelblue",size:64},text:{fill:"#000",font:"sans-serif",fontSize:11}},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domainDefault:!0,domainWidth:1,domainColor:"#000",gridDefault:!1,gridWidth:1,gridColor:"#ddd",gridDash:[],gridOpacity:1,labelDefault:!0,labelColor:"#000",labelFont:"sans-serif",labelFontSize:10,labelPadding:2,tickDefault:!0,tickRound:!0,tickSize:5,tickWidth:1,tickColor:"#000",titleAlign:"center",titlePadding:2,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold"},legend:{orient:"right",offset:18,padding:0,entryPadding:5,titlePadding:5,gradientWidth:100,gradientHeight:20,gradientStrokeColor:"#ddd",gradientStrokeWidth:0,gradientLabelBaseline:"top",gradientLabelOffset:2,labelColor:"#000",labelFontSize:10,labelFont:"sans-serif",labelAlign:"left",labelBaseline:"middle",labelOffset:8,symbolType:"circle",symbolSize:100,symbolColor:"#888",symbolStrokeWidth:1.5,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold",titleAlign:"left",titleBaseline:"top"},range:{category:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}var ht=function(e){return t.isObject(e)?e:t.isNumber(e)?{top:e,bottom:e,left:e,right:e}:{top:0,left:0,bottom:0,right:0}},mt="outer",vt=["value","update","react","bind"],yt=function(e,t){var n=e.name;if(e.push===mt)t.signals[n]||s("No prior signal definition",n),vt.forEach(function(t){void 0!==e[t]&&s("Invalid property ",t)});else{var a=t.addSignal(n,e.value);e.react===!1&&(a.react=!1),e.bind&&t.addBinding(n,e.bind)}},bt=d(i.format),xt=d(o.utcFormat),kt=d(o.timeFormat),St=new Date(2e3,0,1),wt=function(e){var t=this.context.group,n=!1;if(t)for(;e;){if(e===t){n=!0;break}e=e.mark.group}return n},Rt=function(e,t,n){var a,r=e[0],i=e[1];return i<r&&(a=i,i=r,r=a),a=i-r,a>=n-t?[t,n]:[Math.min(Math.max(r,t),n-a),Math.min(Math.max(i,a),n)]},Ot="undefined"!=typeof window&&window||null,zt=function(e){return e[e.length-1]-e[0]},$t="Literal",Et="Identifier",Pt="@",Dt="%",Ft=":",_t=C("area"),jt=C("bounds"),Mt=C("centroid"),At=function(e,t){var n,a=t[0],r=t[t.length-1];return a>r&&(n=a,a=r,r=n),a<=e&&e<=r},Ct=function(e,t,n){if(e){var a=this.context.dataflow,r=e.mark.source;a.pulse(r,a.changeset().encode(e,t))}return void 0!==n?n:e},Wt=function(e,n,a,r,i,o){var l,u,s=this.context.dataflow,d=this.context.data[e],f=d.input,c=d.changes,p=s.stamp();if(s._trigger===!1||!(f.value.length||n||r))return 0;if((!c||c.stamp<p)&&(d.changes=c=s.changeset(),c.stamp=p,s.runAfter(function(){d.modified=!0,s.pulse(f,c).run()})),a&&(l=a===!0?t.truthy:t.isArray(a)||null!=a._id?a:U(a),c.remove(l)),n&&c.insert(n),r&&(l=U(r),f.value.some(l)?c.remove(l):c.insert(r)),i)for(u in o)c.modify(i,u,o[u]);return 1},qt="union",Lt="unit",Vt="others",Ut={pad:t.pad,truncate:t.truncate,rgb:r.rgb,lab:r.lab,hcl:r.hcl,hsl:r.hsl,format:bt,utcFormat:xt,timeFormat:kt,monthFormat:c,monthAbbrevFormat:p,dayFormat:g,dayAbbrevFormat:h,quarter:m,utcquarter:v,warn:b,info:x,debug:k,inScope:wt,clampRange:Rt,pinchDistance:S,pinchAngle:w,open:R,screen:O,windowsize:z,span:zt,bandspace:_,inrange:At,encode:Ct,modify:Wt},Bt=["view","item","group","xy","x","y"],Tt="event.vega.",Nt="this.",It={};X("bandwidth",F,E),X("copy",j,E),X("domain",D,E),X("range",P,E),X("invert",A,E),X("scale",M,E),X("gradient",a.scaleGradient,E),X("geoArea",_t,E),X("geoBounds",jt,E),X("geoCentroid",Mt,E),X("indata",L,V),X("data",W,q),X("vlPoint",I,q),X("vlInterval",J,q);var Jt,Xt={blacklist:["_"],whitelist:["datum","event"],fieldvar:"datum",globalvar:function(e){return"_["+t.stringValue("$"+e)+"]"},functions:Y,constants:n.constants,visitors:It},Yt=n.codegen(Xt),Ht="$",Gt=function(e,a,r){var i,o,l={};try{i=n.parse(e)}catch(n){t.error("Expression parse error: "+t.stringValue(e))}return i.visit(function(e){if("CallExpression"===e.type){var t=e.callee.name,n=Xt.visitors[t];n&&n(t,e.arguments,a,l)}}),o=Yt(i),o.globals.forEach(function(e){var t=Ht+e;!l.hasOwnProperty(t)&&a.getSignal(e)&&(l[t]=a.signalRef(e))}),{$expr:r?r+"return("+o.code+");":o.code,$fields:o.fields,$params:l}},Kt="group",Qt="rect",Zt="rule",en="symbol",tn="text",nn=t.toSet(["*","arc","area","group","image","line","path","rect","rule","shape","symbol","text"]),an=function(e,t){return Jt=t||rn,K(e.trim()).map(Q)},rn="view",on="[",ln="]",un="{",sn="}",dn=":",fn=",",cn="@",pn=">",gn=/[\[\]\{\}]/,hn="view",mn="scope",vn=function(e,t){return e.signal?t.getSignal(e.signal).id:ae(e,t)},yn="var datum=event.item&&event.item.datum;",bn=function(e,n,a){var r,i=e.events,o=e.update,l=e.encode,u=[],s="";i||t.error("Signal update missing events specification."),t.isString(i)&&(i=an(i)),i=t.array(i).filter(function(e){return e.signal?(u.push(e),0):1}),i.length&&u.push(i.length>1?{merge:i}:i[0]),null!=l&&(o&&t.error("Signal encode and update are mutually exclusive."),o="encode(item(),"+t.stringValue(l)+")"),s=t.isString(o)?Gt(o,n,yn):null!=o.expr?Gt(o.expr,n,yn):null!=o.value?o.value:null!=o.signal?{$expr:"_.value",$params:{value:n.signalRef(o.signal)}}:t.error("Invalid signal update specification."),r={target:a,update:s},e.force&&(r.options={force:!0}),u.forEach(function(e){e={source:vn(e,n)},n.addUpdate(t.extend(e,r))})},xn=function(e,t){var n=t.getSignal(e.name);if(e.update){var a=Gt(e.update,t);n.update=a.$expr,n.params=a.$params}e.on&&e.on.forEach(function(e){bn(e,t,n.id)})},kn=function(e,t){var n={};for(var a in e)"name"!==a&&(n[a]=se(e[a],t));t.addProjection(e.name,n)},Sn=t.toSet(["rule"]),wn=function(e,t){var n="";return Sn[t]?n:(e.x2&&(e.x?(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;",n+="o.width=o.x2-o.x;"):n+=e.width?"o.x=o.x2-o.width;":"o.x=o.x2;"),e.xc&&(n+=e.width?"o.x=o.xc-o.width/2;":"o.x=o.xc;"),e.y2&&(e.y?(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;",n+="o.height=o.y2-o.y;"):n+=e.height?"o.y=o.y2-o.height;":"o.y=o.y2;"),e.yc&&(n+=e.height?"o.y=o.yc-o.height/2;":"o.y=o.yc;"),n)},Rn=function(e,t,n,a){function r(e,r,i,o){var l=Dn(null,r,t,n,a),u=Dn(null,i,t,n,a),s=Dn(null,o,t,n,a);return"this."+e+"("+[l,u,s].join(",")+").toString()"}return e.c?r("hcl",e.h,e.c,e.l):e.h||e.s?r("hsl",e.h,e.s,e.l):e.l||e.a?r("lab",e.l,e.a,e.b):e.r||e.g||e.b?r("rgb",e.r,e.g,e.b):null},On=function(e,n,a,r){var i=Gt(e,n);return i.$fields.forEach(function(e){r[e]=1}),t.extend(a,i.$params),i.$expr},zn=function(e,n,a,r){return de(t.isObject(e)?e:{datum:e},n,a,r)},$n=function(e,t,n,a,r){var i,o,l,u=ce(e.scale,n,a,r);return null!=e.range?(i=+e.range,o=u+".range()",t=0===i?o+"[0]":"($="+o+","+(1===i?"$[$.length-1]":"$[0]+"+i+"*($[$.length-1]-$[0])")+")"):(t=null!=t?u+"("+t+")":null,e.band&&(l=fe(e.scale,n))&&(o=u+".bandwidth",i=+e.band,i=o+"()"+(1===i?"":"*"+i),l<0&&(i="("+o+"?"+i+":0)"),t=(t?t+"+":"")+i,e.extra&&(t="(datum.extra?"+u+"(datum.extra.value):"+t+")")),null==t&&(t="0")),t},En=function(e,n,a,r){return"this.gradient("+ce(e.gradient,n,a,r)+","+t.stringValue(e.start)+","+t.stringValue(e.stop)+","+t.stringValue(e.count)+")"},Pn=function(e,n,a,r){return t.isObject(e)?"("+Dn(null,e,n,a,r)+")":e},Dn=function(e,n,a,r,i){if(null!=n.gradient)return En(n,a,r,i);var o=null!=n.color?Rn(n.color,a,r,i):null!=n.field?zn(n.field,a,r,i):null!=n.signal?On(n.signal,a,r,i):null!=n.value?t.stringValue(n.value):null;return null!=n.scale&&(o=$n(n,o,a,r,i)),null!=n.exponent&&(o="Math.pow("+o+","+Pn(n.exponent,a,r,i)+")"),null!=n.mult&&(o+="*"+Pn(n.mult,a,r,i)),null!=n.offset&&(o+="+"+Pn(n.offset,a,r,i)),n.round&&(o="Math.round("+o+")"),o},Fn=function(e,n,a){return e+"["+t.stringValue(n)+"]="+a+";"},_n=function(e,t,n,a,r){var i="";return t.forEach(function(t){var o=Dn(e,t,n,a,r);i+=t.test?On(t.test,n,a,r)+"?"+o+":":o}),Fn("o",e,i)},jn="mark",Mn="frame",An="scope",Cn="axis",Wn="axis-domain",qn="axis-grid",Ln="axis-label",Vn="axis-tick",Un="axis-title",Bn="legend",Tn="legend-entry",Nn="legend-gradient",In="legend-label",Jn="legend-symbol",Xn="legend-title",Yn={name:1,interactive:1},Hn=function(e,t,n,a,r,i){return{type:e,name:i?i.name:void 0,role:t,key:n,from:a,interactive:!(!i||!i.interactive),encode:he(r,i,Yn)}},Gn=function(e,t,n){var a={value:0},r={};return r.enter={opacity:a,x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},stroke:{value:t.gradientStrokeColor},strokeWidth:{value:t.gradientStrokeWidth}},r.exit={opacity:a},r.update={x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},fill:{gradient:e},opacity:{value:1}},Hn(Qt,Nn,void 0,void 0,r,n)},Kn="top",Qn="left",Zn="right",ea="bottom",ta="index",na="label",aa="offset",ra="perc",ia="size",oa="total",la="value",ua="datum."+ra+'<=0?"left":datum.'+ra+'>=1?"right":"center"',sa=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,text:{field:na},fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},baseline:{value:t.gradientLabelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:ra,mult:t.gradientWidth},r.y=i.y={value:t.gradientHeight,offset:t.gradientLabelOffset},r.align=i.align={signal:ua},Hn(tn,In,na,a,l,n)},da=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,fill:{value:t.labelColor},text:{field:na},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},align:{value:t.labelAlign},baseline:{value:t.labelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:aa,offset:t.labelOffset},r.y=i.y={field:ia,mult:.5,offset:{field:oa,offset:{field:{group:"entryPadding"},mult:{field:ta}}}},Hn(tn,In,na,a,l,n)},fa=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,shape:{value:t.symbolType},size:{value:t.symbolSize},strokeWidth:{value:t.symbolStrokeWidth}},e.fill||(r.stroke={value:t.symbolColor}),l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:aa,mult:.5},r.y=i.y={field:ia,mult:.5,offset:{field:oa,offset:{field:{group:"entryPadding"},mult:{field:ta}}}},["shape","size","fill","stroke","opacity"].forEach(function(t){e[t]&&(i[t]=r[t]={scale:e[t],field:la})}),Hn(en,Jn,na,a,l,n)},ca=function(e,t,n,a){var r={value:0},i={};return i.enter={x:{field:{group:"padding"}},y:{field:{group:"padding"}},opacity:r,fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign},baseline:{value:t.titleBaseline}},i.exit={opacity:r},i.update={opacity:{value:1},text:{field:"title"}},Hn(tn,Xn,null,a,i,n)},pa=function(e,t,n,a,r,i){return{type:Kt,name:t,role:e,from:n,interactive:a,encode:r,marks:i}},ga=function(e){return e.role||(e.type===Kt&&(e.legends||e.axes)?An:jn)},ha=function(e){return{clip:e.clip||!1,interactive:e.interactive!==!1,marktype:e.type,name:e.name||void 0,role:ga(e),zindex:+e.zindex||void 0}},ma=function(e){return e},va=we("key"),ya="ascending",ba="descending",xa=Pe("Aggregate"),ka=Pe("AxisTicks"),Sa=Pe("Bound"),wa=Pe("Collect"),Ra=Pe("Compare"),Oa=Pe("DataJoin"),za=Pe("Encode"),$a=Pe("Facet"),Ea=Pe("Field"),Pa=Pe("Key"),Da=Pe("LegendEntries"),Fa=Pe("Mark"),_a=Pe("MultiExtent"),ja=Pe("MultiValues"),Ma=Pe("Params"),Aa=Pe("PreFacet"),Ca=Pe("Projection"),Wa=Pe("Proxy"),qa=Pe("Relay"),La=Pe("Render"),Va=Pe("Scale"),Ua=Pe("Sieve"),Ba=Pe("ViewLayout"),Ta=Pe("Values"),Na=function(e,n){var a=u.definition(e.type);a||t.error("Unrecognized transform type: "+e.type);var r=xe(a.type,null,De(a,e,n));return e.signal&&n.addSignal(e.signal,n.proxy(r)),r.metadata=a.metadata||{},r},Ia=function(e,n,a){var r,i,o,l,u;return e?(r=e.facet)&&(n||t.error("Only group marks can be faceted."),null!=r.field?l=u=Se(a.getData(r.data).output):(i=a.keyRef(r.groupby),e.data?u=a.getData(e.data).aggregate:(o=Na(t.extend({type:"aggregate",groupby:t.array(r.groupby)},r.aggregate)),o.params.key=i,o.params.pulse=Se(a.getData(r.data).output),l=u=Se(a.add(o))))):l=Se(a.add(wa(null,[{}]))),l||(l=e.$ref?e:Se(e.mark?a.getData(ma(e.mark)).output:a.getData(e.data).output)),{key:i,pulse:l,parent:u}};Be.fromEntries=function(e,t){var n=t.length,a=1,r=t[0],i=t[n-1],o=t[n-2],l=null;for(e.add(t[0]);a<n;++a)t[a].params.pulse=Se(t[a-1]),e.add(t[a]),"Aggregate"===t[a].type&&(l=t[a]);return new Be(e,r,o,i,l)};var Ja=Be.prototype;Ja.countsRef=function(e,t,n){var a,r,i,o=this,l=o.counts||(o.counts={}),u=Te(t);return null!=u&&(e=o.scope,a=l[u]),a?n&&n.field&&Ne(e,a.agg.params,n):(i={groupby:e.fieldRef(t,"key"),pulse:Se(o.output)},n&&n.field&&Ne(e,i,n),r=e.add(xa(i)),a=e.add(wa({pulse:Se(r)})),a={agg:r,ref:Se(a)},null!=u&&(l[u]=a)),a.ref},Ja.tuplesRef=function(){return Se(this.values)},Ja.extentRef=function(e,t){return Ie(e,this,"extent","Extent",t,!1)},Ja.domainRef=function(e,t){return Ie(e,this,"domain","Values",t,!1)},Ja.valuesRef=function(e,t,n){return Ie(e,this,"vals","Values",t,n||!0)},Ja.lookupRef=function(e,t){return Ie(e,this,"lookup","TupleIndex",t,!1)},Ja.indataRef=function(e,t){return Ie(e,this,"indata","TupleIndex",t,!0,!0)};var Xa=function(e,n,a){var r,i,o,l,u=e.from.facet,s=u.name,d=Se(n.getData(u.data).output);u.name||t.error("Facet must have a name: "+JSON.stringify(u)),u.data||t.error("Facet must reference a data set: "+JSON.stringify(u)),u.field?l=n.add(Aa({field:n.fieldRef(u.field),pulse:d})):u.groupby?l=n.add($a({key:n.keyRef(u.groupby),group:n.proxy(a.parent),pulse:d})):t.error("Facet must specify groupby or field: "+JSON.stringify(u)),r=n.fork(),i=r.add(wa()),o=r.add(Ua({pulse:Se(i)})),r.addData(s,new Be(r,i,i,o)),r.addSignal("parent",null),l.params.subflow={$subflow:sr(e,r).toRuntime()}},Ya=function(e,t,n){var a=t.add(Aa({pulse:n.pulse})),r=t.fork();r.add(Ua()),r.addSignal("parent",null),a.params.subflow={$subflow:sr(e,r).toRuntime()}},Ha=function(e,t,n){var a,r,i=e.remove,o=e.insert,l=e.toggle,u=e.modify,s=e.values,d=t.add(ke());a="if("+e.trigger+',modify("'+n+'",'+[o,i,l,u,s].map(function(e){return null==e?"null":e}).join(",")+"),0)",r=Gt(a,t),d.update=r.$expr,d.params=r.$params},Ga=function(e,n){var a,r,i,o,l,u,s,d,f,c,p=ga(e),g=e.type===Kt,h=e.from&&e.from.facet,m=p===An||p===Mn;r=Ia(e.from,g,n),a=n.add(Oa({key:r.key,pulse:r.pulse,clean:!g})),a=i=n.add(wa({pulse:Se(a)})),a=n.add(Fa({markdef:ha(e),scenepath:{$itempath:n.markpath()},pulse:Se(a)})),d=Se(a),a=n.add(za(me(e.encode,e.type,p,n,{pulse:d}))),a.params.parent=n.encode(),e.transform&&e.transform.forEach(function(e){var r=Na(e,n);(r.metadata.generates||r.metadata.changes)&&t.error("Mark transforms should not generate new data."),r.params.pulse=Se(a),n.add(a=r)}),f=Se(a),(h||m)&&(a=n.add(Ba({legendMargin:n.config.legendMargin,mark:d,pulse:f})),n.operators.pop(),n.pushState(f,Se(a)),h?Xa(e,n,r):Ya(e,n,r),n.popState(),n.operators.push(a)),o=n.add(Sa({mark:d,pulse:Se(a)})),c=Se(o),!g||h||m||(n.pushState(f,c),p===jn?Ya(e,n,r):sr(e,n),n.popState()),l=n.add(La({pulse:c})),u=n.add(Ua({pulse:c},void 0,n.parent())),null!=e.name&&(s=ma(e.name),n.addData(s,new Be(n,i,l,u)),e.on&&e.on.forEach(function(e){(e.insert||e.remove||e.toggle)&&t.error("Marks only support modify triggers."), | ||
Ha(e,n,s)}))},Ka=function(e,n){var a,r,i,o,l,u,s,d,f=e.type||"symbol",c=n.config.legend,p=e.name||void 0,g=e.encode||{},h=!!e.interactive,m=e.size||e.shape||e.fill||e.stroke||e.opacity;return m||t.error("Missing valid scale for legend."),a={orient:Je(e.orient,c.orient),title:e.title},r=Se(n.add(wa(null,[a]))),u=he({update:{offset:ge(Je(e.offset,c.offset)),padding:ge(Je(e.padding,c.padding)),titlePadding:ge(Je(e.titlePadding,c.titlePadding))}},g.legend),s={update:{x:{field:{group:"padding"}},y:{field:{group:"padding"}},entryPadding:ge(Je(e.entryPadding,c.entryPadding))}},"gradient"===f?(i=Se(n.add(Da({type:"gradient",scale:n.scaleRef(m),count:n.property(e.tickCount),values:n.property(e.values),formatSpecifier:n.property(e.format)}))),d=[Gn(m,c,g.gradient),sa(e,c,g.labels,i)]):(i=Se(n.add(Da({size:Xe(e,c,g.labels),scale:n.scaleRef(m),count:n.property(e.tickCount),values:n.property(e.values),formatSpecifier:n.property(e.formatSpecifier)}))),d=[fa(e,c,g.symbols,i),da(e,c,g.labels,i)]),d=[pa(Tn,null,r,h,s,d)],a.title&&(l=ca(e,c,g.title,r),s.update.y.offset={field:{group:"titlePadding"},offset:l.encode.update.fontSize||l.encode.enter.fontSize},d.push(l)),o=pa(Bn,p,r,h,u,d),e.zindex&&(o.zindex=e.zindex),Ga(o,n)},Qa=["identity","ordinal","band","point","index","linear","pow","sqrt","log","sequential","time","utc","quantize","quantile","threshold"],Za=t.toSet(Qa),er=t.toSet(Qa.slice(1,5)),tr=function(e,n){var a,r,i=e.type||"linear";Za.hasOwnProperty(i)||t.error("Unrecognized scale type: "+i),a={type:i,domain:Qe(e.domain,e,n)},null!=e.range&&(null!=e.rangeStep&&t.error("Scale range and rangeStep are mutually exclusive."),a.range=ot(e,n));for(r in e)a[r]||"name"===r||(a[r]=Ge(e[r],n));n.addScale(e.name,a)},nr=function(e,n){var a=n.config,r=e.orient,i=r===Kn||r===ea?a.axisX:a.axisY,o=a["axis"+r[0].toUpperCase()+r.slice(1)],l="band"===n.scaleType(e.scale)&&a.axisBand;return i||o||l?t.extend({},a.axis,i,o,l):a.axis},ar=function(e,t,n,a){var r,i,o,l,u,s=e.orient,d={value:0},f={};return f.enter=r={opacity:d,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},f.exit={opacity:d},f.update=i={opacity:{value:1}},s===Kn||s===ea?(o="x",u="y"):(o="y",u="x"),l=o+"2",r[u]=d,i[o]=r[o]=dt(e,0),i[l]=r[l]=dt(e,1),Hn(Zt,Wn,null,a,f,n)},rr=function(e,t,n,a){var r,i,o,l,u,s,d,f,c=e.orient,p=e.gridScale,g=c===Qn||c===Kn?1:-1,h=g*e.offset||0,m={value:0},v={};return v.enter=r={opacity:m,stroke:{value:t.gridColor},strokeWidth:{value:t.gridWidth},strokeDash:{value:t.gridDash}},v.exit=i={opacity:m},v.update=o={opacity:{value:t.gridOpacity}},l={scale:e.scale,field:la,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},c===Kn||c===ea?(u="x",s="y",f="height"):(u="y",s="x",f="width"),d=s+"2",o[u]=r[u]=i[u]=l,p?(r[s]={scale:p,range:0,mult:g,offset:h},o[d]=r[d]={scale:p,range:1,mult:g,offset:h}):(r[s]={value:h},o[d]=r[d]={signal:f,mult:g,offset:h}),Hn(Zt,qn,la,a,v,n)},ir=function(e,t,n,a,r){var i,o,l,u,s,d=e.orient,f=d===Qn||d===Kn?-1:1,c={value:0},p={};return p.enter=i={opacity:c,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},p.exit=o={opacity:c},p.update=l={opacity:{value:1}},u=ge(r),u.mult=f,s={scale:e.scale,field:la,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},d===Kn||d===ea?(l.y=i.y=c,l.y2=i.y2=u,l.x=i.x=o.x=s):(l.x=i.x=c,l.x2=i.x2=u,l.y=i.y=o.y=s),Hn(Zt,Vn,na,a,p,n)},or=function(e,t,n,a,r){var i,o,l,u,s,d=e.orient,f=d===Qn||d===Kn?-1:1,c=null!=e.labelPadding?e.labelPadding:t.labelPadding,p={value:0},g={};return g.enter=i={opacity:p,fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},text:{field:na}},g.exit=o={opacity:p},g.update=l={opacity:{value:1}},u=ge(r),u.mult=f,u.offset=ge(c),u.offset.mult=f,s={scale:e.scale,field:la,band:.5},d===Kn||d===ea?(l.y=i.y=u,l.x=i.x=o.x=s,l.align={value:"center"},l.baseline={value:d===Kn?"bottom":"top"}):(l.x=i.x=u,l.y=i.y=o.y=s,l.align={value:d===Zn?"left":"right"},l.baseline={value:"middle"}),Hn(tn,Ln,na,a,g,n)},lr=function(e,t,n,a){var r,i,o=e.orient,l=o===Qn||o===Kn?-1:1,u=o===Kn||o===ea,s={};return s.enter={opacity:{value:0},fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign}},s.exit={opacity:{value:0}},s.update=r={opacity:{value:1},text:{field:"title"}},i={scale:e.scale,range:.5},u?(r.x=i,r.angle={value:0},r.baseline={value:o===Kn?"bottom":"top"}):(r.y=i,r.angle={value:90*l},r.baseline={value:"bottom"}),null!=t.titleAngle&&(r.angle={value:t.titleAngle}),null!=t.titleBaseline&&(r.baseline={value:t.titleBaseline}),null!=t.titleX?r.x={value:t.titleX}:u&&!ye(n,"x")&&(s.enter.auto={value:!0}),null!=t.titleY?r.y={value:t.titleY}:u||ye(n,"y")||(s.enter.auto={value:!0}),Hn(tn,Un,null,a,s,n)},ur=function(e,t){var n,a,r,i,o,l,u,s=nr(e,t),d=e.name||void 0,f=e.encode||{},c=!!e.interactive;return n={orient:e.orient,tick:null!=e.tick?!!e.tick:s.tickDefault,label:null!=e.label?!!e.label:s.labelDefault,grid:null!=e.grid?!!e.grid:s.gridDefault,domain:null!=e.domain?!!e.domain:s.domainDefault,title:e.title},a=Se(t.add(wa({},[n]))),l=he({update:{range:{expr:'abs(span(range("'+e.scale+'")))'},offset:ge(e.offset||0),position:ge(e.position||0),titlePadding:ge(e.titlePadding||s.titlePadding),minExtent:ge(e.minExtent||s.minExtent),maxExtent:ge(e.maxExtent||s.maxExtent)}},f.axis),r=Se(t.add(ka({scale:t.scaleRef(e.scale),extra:s.tickExtra,count:t.property(e.tickCount),values:t.property(e.values),formatSpecifier:t.property(e.format)}))),u=[],n.grid&&u.push(rr(e,s,f.grid,r)),n.tick&&(i=null!=e.tickSize?e.tickSize:s.tickSize,u.push(ir(e,s,f.ticks,r,i))),n.label&&(i=n.tick?i:0,u.push(or(e,s,f.labels,r,i))),n.domain&&u.push(ar(e,s,f.domain,a)),n.title&&u.push(lr(e,s,f.title,a)),o=pa(Cn,d,a,c,l,u),e.zindex&&(o.zindex=e.zindex),Ga(o,t)},sr=function(e,n,a){var r=t.array(e.signals);return a||r.forEach(function(e){yt(e,n)}),t.array(e.projections).forEach(function(e){kn(e,n)}),t.array(e.data).forEach(function(e){lt(e,n)}),t.array(e.scales).forEach(function(e){tr(e,n)}),r.forEach(function(e){xn(e,n)}),n.parseLambdas(),t.array(e.axes).forEach(function(e){ur(e,n)}),t.array(e.marks).forEach(function(e){Ga(e,n)}),t.array(e.legends).forEach(function(e){Ka(e,n)}),n},dr=t.toSet(["width","height","padding"]),fr=ct.prototype=pt.prototype;fr.fork=function(){return new pt(this)},fr.toRuntime=function(){return this.finish(),{background:this.background,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings}},fr.id=function(){return(this._subid?this._subid+":":0)+this._id++},fr.add=function(e){return this.operators.push(e),e.id=this.id(),e.refs&&(e.refs.forEach(function(t){t.$ref=e.id}),e.refs=null),e},fr.proxy=function(e){var t=e instanceof be?Se(e):e;return this.add(Wa({value:t}))},fr.addStream=function(e){return this.streams.push(e),e.id=this.id(),e},fr.addUpdate=function(e){return this.updates.push(e),e},fr.finish=function(){function e(e,t,n){var a,r;e&&(a=e.data||(e.data={}),r=a[t]||(a[t]=[]),r.push(n))}var t,n;this.root&&(this.root.root=!0);for(t in this.signals)this.signals[t].signal=t;for(t in this.scales)this.scales[t].scale=t;for(t in this.data){n=this.data[t],e(n.input,t,"input"),e(n.output,t,"output"),e(n.values,t,"values");for(var a in n.index)e(n.index[a],t,"index:"+a)}return this},fr.pushState=function(e,t){this._encode.push(Se(this.add(Ua({pulse:e})))),this._parent.push(t),this._markpath.push(-1)},fr.popState=function(){this._parent.pop(),this._encode.pop(),this._markpath.pop()},fr.parent=function(){return t.peek(this._parent)},fr.encode=function(){return t.peek(this._encode)},fr.markpath=function(){var e=this._markpath;return++e[e.length-1],e.slice()},fr.fieldRef=function(e,n){if(t.isString(e))return we(e,n);e.signal||t.error("Unsupported field reference: "+JSON.stringify(e));var a,r=e.signal,i=this.field[r];return i||(a={name:this.signalRef(r)},n&&(a.as=n),this.field[r]=i=Se(this.add(Ea(a)))),i},fr.compareRef=function(e){function n(e){return Ee(e)?(r=!0,Se(a[e.signal])):e}var a=this.signals,r=!1,i=t.array(e.field).map(n),o=t.array(e.order).map(n);return r?Se(this.add(Ra({fields:i,orders:o}))):Re(i,o)},fr.keyRef=function(e){function n(e){return Ee(e)?(r=!0,Se(a[e.signal])):e}var a=this.signals,r=!1;return e=t.array(e).map(n),r?Se(this.add(Pa({fields:e}))):Oe(e)},fr.sortRef=function(e){if(!e)return e;var t=[$e(e.op,e.field),"_id"],n=e.order||ya;return n.signal?Se(this.add(Ra({fields:t,orders:[n=this.signalRef(n.signal),n]}))):Re(t,[n,n])},fr.event=function(e,t){var n=e+":"+t;if(!this.events[n]){var a=this.id();this.streams.push({id:a,source:e,type:t}),this.events[n]=a}return this.events[n]},fr.addSignal=function(e,n){this.signals.hasOwnProperty(e)&&t.error("Duplicate signal name: "+e);var a=n instanceof be?n:this.add(ke(n));return this.signals[e]=a},fr.getSignal=function(e){return this.signals[e]||t.error("Unrecognized signal name: "+e),this.signals[e]},fr.signalRef=function(e){return this.signals[e]?Se(this.signals[e]):(this.lambdas[e]||(this.lambdas[e]=this.add(ke(null))),Se(this.lambdas[e]))},fr.parseLambdas=function(){for(var e=Object.keys(this.lambdas),t=0,n=e.length;t<n;++t){var a=e[t],r=Gt(a,this),i=this.lambdas[a];i.params=r.$params,i.update=r.$expr}},fr.property=function(e){return e&&e.signal?this.signalRef(e.signal):e},fr.addBinding=function(e,n){this.bindings||t.error("Nested signals do not support binding: "+e),this.bindings.push(t.extend({signal:e},n))},fr.addScaleProj=function(e,n){this.scales.hasOwnProperty(e)&&t.error("Duplicate scale or projection name: "+e),this.scales[e]=this.add(n)},fr.addScale=function(e,t){this.addScaleProj(e,Va(t))},fr.addProjection=function(e,t){this.addScaleProj(e,Ca(t))},fr.getScale=function(e){return this.scales[e]||t.error("Unrecognized scale name: "+e),this.scales[e]},fr.projectionRef=fr.scaleRef=function(e){return Se(this.getScale(e))},fr.projectionType=fr.scaleType=function(e){return this.getScale(e).params.type},fr.addData=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.data[e]=n},fr.getData=function(e){return this.data[e]||t.error("Undefined data set name: "+e),this.data[e]},fr.addDataPipeline=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.addData(e,Be.fromEntries(this,n))};var cr=function(e){var n,a=gt();for(n in e)a[n]=t.isObject(a[n])?t.extend(a[n],e[n]):a[n]=e[n];return a},pr=function(e,t){return ft(e,new ct(cr(t||e.config))).toRuntime()};e.parse=pr,e.selector=an,e.signal=yt,e.signalUpdates=xn,e.stream=vn,e.codeGenerator=Yt,e.functionContext=Ut,e.expressionFunction=X,e.MarkRole=jn,e.FrameRole=Mn,e.ScopeRole=An,e.AxisRole=Cn,e.AxisDomainRole=Wn,e.AxisGridRole=qn,e.AxisLabelRole=Ln,e.AxisTickRole=Vn,e.AxisTitleRole=Un,e.LegendRole=Bn,e.LegendEntryRole=Tn,e.LegendLabelRole=In,e.LegendSymbolRole=Jn,e.LegendTitleRole=Xn,e.marktypes=nn,e.isMarkType=H,e.Scope=ct,e.DataScope=Be,e.formatLocale=i.formatDefaultLocale,e.timeFormatLocale=o.timeFormatDefaultLocale,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-parser", | ||
"version": "1.0.0-beta.21", | ||
"version": "1.0.0-beta.22", | ||
"description": "Parse Vega specifications to runtime dataflows.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -20,4 +20,3 @@ import {codegen, constants, functions} from 'vega-expression'; | ||
import {geoArea, geoBounds, geoCentroid} from './geo'; | ||
import {tuples, tuplesVisitor} from './tuples'; | ||
import {indata, indataVisitor} from './indata'; | ||
import {data, indata, dataVisitor, indataVisitor} from './data'; | ||
import inrange from './inrange'; | ||
@@ -59,5 +58,3 @@ import encode from './encode'; | ||
encode: encode, | ||
modify: modify, | ||
vlPoint: vlPoint, | ||
vlInterval: vlInterval | ||
modify: modify | ||
}; | ||
@@ -99,3 +96,5 @@ | ||
expressionFunction('indata', indata, indataVisitor); | ||
expressionFunction('tuples', tuples, tuplesVisitor); | ||
expressionFunction('data', data, dataVisitor); | ||
expressionFunction('vlPoint', vlPoint, dataVisitor); | ||
expressionFunction('vlInterval', vlInterval, dataVisitor); | ||
@@ -102,0 +101,0 @@ // Build expression function registry |
@@ -6,3 +6,3 @@ import {isArray, truthy} from 'vega-util'; | ||
for (var key in props) { | ||
if (_[key] !== props[key]) return false; | ||
if (key !== '_id' && _[key] !== props[key]) return false; | ||
} | ||
@@ -21,3 +21,3 @@ return true; | ||
if (!(input.value.length || insert || toggle)) { | ||
if (df._trigger === false || !(input.value.length || insert || toggle)) { | ||
// nothing to do! | ||
@@ -31,2 +31,3 @@ return 0; | ||
df.runAfter(function() { | ||
data.modified = true; | ||
df.pulse(input, changes).run(); | ||
@@ -49,3 +50,3 @@ }); | ||
predicate = removePredicate(toggle); | ||
if (input.value.filter(predicate).length) { | ||
if (input.value.some(predicate)) { | ||
changes.remove(predicate); | ||
@@ -52,0 +53,0 @@ } else { |
export var indexPrefix = '@'; | ||
export var scalePrefix = '%'; | ||
export var tuplePrefix = ':'; | ||
export var dataPrefix = ':'; |
@@ -18,3 +18,3 @@ import {error, stringValue} from 'vega-util'; | ||
OUTER_INVALID.forEach(function(prop) { | ||
if (signal[prop] !== undefined) error('Invalid property', prop); | ||
if (signal[prop] !== undefined) outerError('Invalid property ', prop); | ||
}); | ||
@@ -21,0 +21,0 @@ } else { |
Sorry, the diff of this file is too big to display
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
345548
9864
106