-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvega.min.js
2 lines (2 loc) · 61 KB
/
vega.min.js
1
2
vg=function(e){function r(e){t.config.isNode?process.stderr.write(e+"\n"):console.log(e)}function o(e){return i.test(e)}function u(e){return e.indexOf(s)===0}function a(n,r){t.log("LOAD: "+n),e.xhr(n,function(e,t){t&&(t=t.responseText),r(e,t)})}function f(e,n){t.log("LOAD FILE: "+e);var r=e.indexOf(s);r>=0&&(e=e.slice(s.length)),require("fs").readFile(e,n)}function l(e,n){t.log("LOAD HTTP: "+e);var r=require("http").request(e,function(e){var t=0,r=new Buffer(parseInt(e.headers["content-length"],10));e.on("error",function(e){n(e,null)}),e.on("data",function(e){e.copy(r,t),t+=e.length}),e.on("end",function(){n(null,r)})});r.on("error",function(e){n(e)}),r.end()}function p(e,t,n){i=[];if(n&&t.length>1){var r=d(e.domain()),i,s=-1,o=t.length,u=(t[1]-t[0])/++n,a,f;while(++s<o)for(a=n;--a>0;)(f=+t[s]-a*u)>=r[0]&&i.push(f);for(--s,a=0;++a<n&&(f=+t[s]+a*u)<r[1];)i.push(f)}return i}function d(e){var t=e[0],n=e[e.length-1];return t<n?[t,n]:[n,t]}function v(e){return e.rangeExtent?e.rangeExtent():d(e.range())}function b(e,n,r,i,s,o){s=Math.max(s,0)+o;if(e==="left"||e==="top")s*=-1;e==="top"||e==="bottom"?(t.extend(n.properties.enter,{x:r,y:{value:s}}),t.extend(n.properties.update,{x:i,y:{value:s},align:{value:"center"},baseline:{value:g[e]}})):(t.extend(n.properties.enter,{x:{value:s},y:r}),t.extend(n.properties.update,{x:{value:s},y:i,align:{value:m[e]},baseline:{value:"middle"}}))}function w(e,n,r,i,s){var o=e==="left"||e==="top"?-1:1;s===Infinity?s=e==="top"||e==="bottom"?{group:"height",mult:-o}:{group:"width",mult:-o}:s={value:o*s},e==="top"||e==="bottom"?(t.extend(n.properties.enter,{x:r,y:{value:0},y2:s}),t.extend(n.properties.update,{x:i,y:{value:0},y2:s}),t.extend(n.properties.exit,{x:i})):(t.extend(n.properties.enter,{x:{value:0},x2:s,y:r}),t.extend(n.properties.update,{x:{value:0},x2:s,y:i}),t.extend(n.properties.exit,{y:i}))}function E(e,t,n,r){var i;if(e==="top"||e==="left")r=-1*r;e==="bottom"||e==="top"?i="M"+n[0]+","+r+"V0H"+n[1]+"V"+r:i="M"+r+","+n[0]+"H0V"+n[1]+"H"+r,t.properties.update.path={value:i}}function S(e,t,n){var r=n?{}:e,i=e.mark.def.offset,s=e.mark.def.orient,o=t.width,u=t.height;e.width=o,e.height=u;switch(s){case"left":r.x=-i,r.y=0;break;case"right":r.x=o+i,r.y=0;break;case"bottom":r.x=0,r.y=u+i;break;case"top":r.x=0,r.y=-i;break;default:r.x=0,r.y=0}n&&n.interpolate(e,r)}function T(){return{type:"rule",interactive:!1,key:"data",properties:{enter:{stroke:{value:t.config.axis.tickColor},strokeWidth:{value:t.config.axis.tickWidth},opacity:{value:1e-6}},exit:{opacity:{value:1e-6}},update:{opacity:{value:1}}}}}function N(){return{type:"text",interactive:!1,key:"data",properties:{enter:{fill:{value:t.config.axis.tickLabelColor},font:{value:t.config.axis.tickLabelFont},fontSize:{value:t.config.axis.tickLabelFontSize},opacity:{value:1e-6},text:{field:"label"}},exit:{opacity:{value:1e-6}},update:{opacity:{value:1}}}}}function C(){return{type:"path",interactive:!1,properties:{enter:{x:{value:.5},y:{value:.5},stroke:{value:t.config.axis.axisColor},strokeWidth:{value:t.config.axis.axisWidth}},update:{}}}}var t={};t.version="1.3.0";var n=Object.prototype.toString;t.isObject=function(e){return e===Object(e)},t.isFunction=function(e){return n.call(e)=="[object Function]"},t.isString=function(e){return n.call(e)=="[object String]"},t.isArray=Array.isArray||function(e){return n.call(e)=="[object Array]"},t.isNumber=function(e){return n.call(e)=="[object Number]"},t.isBoolean=function(e){return n.call(e)=="[object Boolean]"},t.number=function(e){return+e},t.boolean=function(e){return!!e},t.identity=function(e){return e},t.extend=function(e){for(var t,n,r=1,i=arguments.length;r<i;++r){t=arguments[r];for(n in t)e[n]=t[n]}return e},t.duplicate=function(e){return JSON.parse(JSON.stringify(e))},t.field=function(e){return e.split("\\.").map(function(e){return e.split(".")}).reduce(function(e,t){return e.length&&(e[e.length-1]+="."+t.shift()),e.push.apply(e,t),e},[])},t.accessor=function(e){var n;return t.isFunction(e)||e==null?e:t.isString(e)&&(n=t.field(e)).length>1?function(e){return n.reduce(function(e,t){return e[t]},e)}:function(t){return t[e]}},t.comparator=function(e){var n=[];return e===undefined&&(e=[]),e=t.array(e).map(function(e){var r=1;return e[0]==="-"?(r=-1,e=e.slice(1)):e[0]==="+"&&(r=1,e=e.slice(1)),n.push(r),t.accessor(e)}),function(t,r){var i,s,o,u,a;for(i=0,s=e.length;i<s;++i){o=e[i],u=o(t),a=o(r);if(u<a)return-1*n[i];if(u>a)return n[i]}return 0}},t.numcmp=function(e,t){return e-t},t.array=function(e){return e!=null?t.isArray(e)?e:[e]:[]},t.values=function(e){return t.isObject(e)&&!t.isArray(e)&&e.values?e.values:e},t.str=function(e){return t.isArray(e)?"["+e.map(t.str)+"]":t.isString(e)?"'"+e+"'":e},t.keys=function(e){var t=[];for(var n in e)t.push(n);return t},t.unique=function(e,n){n=n||t.identity;var r=[],i;for(var s=0;s<e.length;++s)i=n(e[s]),r.indexOf(i)<0&&r.push(i);return r},t.log=function(e){r("[Vega Log] "+e)},t.error=function(e){e="[Vega Err] "+e,r(e),typeof alert!="undefined"&&alert(e)},t.config={},t.config.isNode=typeof exports!="undefined"&&this.exports!==exports,t.config.baseURL="",t.config.svgNamespace='version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"',t.config.axis={ticks:10,padding:3,axisColor:"#000",gridColor:"#ccc",tickColor:"#000",tickLabelColor:"#000",axisWidth:1,tickWidth:1,tickSize:6,tickLabelFontSize:11,tickLabelFont:"sans-serif"},t.config.range={category10:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],category20:["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],shapes:["circle","cross","diamond","square","triangle-down","triangle-up"]},t.Bounds=function(){var e=function(e){this.clear(),e&&this.union(e)},t=e.prototype;return t.clear=function(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},t.set=function(e,t,n,r){return this.x1=e,this.y1=t,this.x2=n,this.y2=r,this},t.add=function(e,t){return e<this.x1&&(this.x1=e),t<this.y1&&(this.y1=t),e>this.x2&&(this.x2=e),t>this.y2&&(this.y2=t),this},t.expand=function(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},t.round=function(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},t.translate=function(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this},t.rotate=function(e,t,n){var r=Math.cos(e),i=Math.sin(e),s=t-t*r+n*i,o=n-t*i-n*r,u=this.x1,a=this.x2,f=this.y1,l=this.y2;return this.clear().add(r*u-i*f+s,i*u+r*f+o).add(r*u-i*l+s,i*u+r*l+o).add(r*a-i*f+s,i*a+r*f+o).add(r*a-i*l+s,i*a+r*l+o)},t.union=function(e){return e.x1<this.x1&&(this.x1=e.x1),e.y1<this.y1&&(this.y1=e.y1),e.x2>this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},t.encloses=function(e){return e&&this.x1<=e.x1&&this.x2>=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},t.intersects=function(e){return e&&!(this.x2<e.x1||this.x1>e.x2||this.y2<e.y1||this.y1>e.y2)},t.contains=function(e,t){return!(e<this.x1||e>this.x2||t<this.y1||t>this.y2)},t.width=function(){return this.x2-this.x1},t.height=function(){return this.y2-this.y1},e}(),t.canvas={},t.canvas.path=function(){function r(t){var r=[],i,s,o;t=t.slice().replace(n[0],"###$1").split(n[1]).slice(1);for(var u=0,a,f,l=t.length;u<l;u++){i=t[u],s=i.slice(1).trim().replace(n[2],"$1###-").split(n[3]),f=[i.charAt(0)];for(var a=0,c=s.length;a<c;a++)o=parseFloat(s[a]),isNaN(o)||f.push(o);var h=f[0].toLowerCase(),p=e[h];if(f.length-1>p)for(var d=1,v=f.length;d<v;d+=p)r.push([f[0]].concat(f.slice(d,d+p)));else r.push(f)}return r}function i(e,t,n,r,i,s,o){var u=r[0],a=r[1],c=r[2],h=r[3],p=r[4],d=r[5],v=r[6],m=f(d,v,u,a,h,p,c,t,n);for(var g=0;g<m.length;g++){var y=l.apply(null,m[g]);e.bezierCurveTo.apply(e,y),i.add(y[0]-s,y[1]-o),i.add(y[2]-s,y[3]-o),i.add(y[4]-s,y[5]-o)}}function f(e,t,n,r,i,o,f,l,c){a=u.call(arguments);if(s[a])return s[a];var h=f*(Math.PI/180),p=Math.sin(h),d=Math.cos(h);n=Math.abs(n),r=Math.abs(r);var v=d*(l-e)*.5+p*(c-t)*.5,m=d*(c-t)*.5-p*(l-e)*.5,g=v*v/(n*n)+m*m/(r*r);g>1&&(g=Math.sqrt(g),n*=g,r*=g);var y=d/n,b=p/n,w=-p/r,E=d/r,S=y*l+b*c,x=w*l+E*c,T=y*e+b*t,N=w*e+E*t,C=(T-S)*(T-S)+(N-x)*(N-x),k=1/C-.25;k<0&&(k=0);var L=Math.sqrt(k);o==i&&(L=-L);var A=.5*(S+T)-L*(N-x),O=.5*(x+N)+L*(T-S),M=Math.atan2(x-O,S-A),_=Math.atan2(N-O,T-A),D=_-M;D<0&&o==1?D+=2*Math.PI:D>0&&o==0&&(D-=2*Math.PI);var P=Math.ceil(Math.abs(D/(Math.PI*.5+.001))),H=[];for(var B=0;B<P;B++){var j=M+B*D/P,F=M+(B+1)*D/P;H[B]=[A,O,j,F,n,r,p,d]}return s[a]=H}function l(e,t,n,r,i,s,f,l){a=u.call(arguments);if(o[a])return o[a];var c=l*i,h=-f*s,p=f*i,d=l*s,v=Math.cos(n),m=Math.sin(n),g=Math.cos(r),y=Math.sin(r),b=.5*(r-n),w=Math.sin(b*.5),E=8/3*w*w/Math.sin(b),S=e+v-E*m,x=t+m+E*v,T=e+g,N=t+y,C=T+E*y,k=N-E*g;return o[a]=[c*S+h*x,p*S+d*x,c*C+h*k,p*C+d*k,c*T+h*N,p*T+d*N]}function c(e,n,r,s){var o,u=null,a=0,f=0,l=0,c=0,h,p,d,v,m=new t.Bounds;r==undefined&&(r=0),s==undefined&&(s=0),e.beginPath();for(var g=0,y=n.length;g<y;++g){o=n[g];switch(o[0]){case"l":a+=o[1],f+=o[2],e.lineTo(a+r,f+s),m.add(a,f);break;case"L":a=o[1],f=o[2],e.lineTo(a+r,f+s),m.add(a,f);break;case"h":a+=o[1],e.lineTo(a+r,f+s),m.add(a,f);break;case"H":a=o[1],e.lineTo(a+r,f+s),m.add(a,f);break;case"v":f+=o[1],e.lineTo(a+r,f+s),m.add(a,f);break;case"V":f=o[1],e.lineTo(a+r,f+s),m.add(a,f);break;case"m":a+=o[1],f+=o[2],e.moveTo(a+r,f+s),m.add(a,f);break;case"M":a=o[1],f=o[2],e.moveTo(a+r,f+s),m.add(a,f);break;case"c":h=a+o[5],p=f+o[6],l=a+o[3],c=f+o[4],e.bezierCurveTo(a+o[1]+r,f+o[2]+s,l+r,c+s,h+r,p+s),m.add(a+o[1],f+o[2]),m.add(l,c),m.add(h,p),a=h,f=p;break;case"C":a=o[5],f=o[6],l=o[3],c=o[4],e.bezierCurveTo(o[1]+r,o[2]+s,l+r,c+s,a+r,f+s),m.add(o[1],o[2]),m.add(l,c),m.add(a,f);break;case"s":h=a+o[3],p=f+o[4],l=2*a-l,c=2*f-c,e.bezierCurveTo(l+r,c+s,a+o[1]+r,f+o[2]+s,h+r,p+s),m.add(l,c),m.add(a+o[1],f+o[2]),m.add(h,p),l=a+o[1],c=f+o[2],a=h,f=p;break;case"S":h=o[3],p=o[4],l=2*a-l,c=2*f-c,e.bezierCurveTo(l+r,c+s,o[1]+r,o[2]+s,h+r,p+s),a=h,f=p,m.add(o[1],o[2]),m.add(l,c),m.add(h,p),l=o[1],c=o[2];break;case"q":h=a+o[3],p=f+o[4],l=a+o[1],c=f+o[2],e.quadraticCurveTo(l+r,c+s,h+r,p+s),a=h,f=p,m.add(l,c),m.add(h,p);break;case"Q":h=o[3],p=o[4],e.quadraticCurveTo(o[1]+r,o[2]+s,h+r,p+s),a=h,f=p,l=o[1],c=o[2],m.add(l,c),m.add(h,p);break;case"t":h=a+o[1],p=f+o[2],u[0].match(/[QqTt]/)===null?(l=a,c=f):u[0]==="t"?(l=2*a-d,c=2*f-v):u[0]==="q"&&(l=2*a-l,c=2*f-c),d=l,v=c,e.quadraticCurveTo(l+r,c+s,h+r,p+s),a=h,f=p,l=a+o[1],c=f+o[2],m.add(l,c),m.add(h,p);break;case"T":h=o[1],p=o[2],l=2*a-l,c=2*f-c,e.quadraticCurveTo(l+r,c+s,h+r,p+s),a=h,f=p,m.add(l,c),m.add(h,p);break;case"a":i(e,a+r,f+s,[o[1],o[2],o[3],o[4],o[5],o[6]+a+r,o[7]+f+s],m,r,s),a+=o[6],f+=o[7];break;case"A":i(e,a+r,f+s,[o[1],o[2],o[3],o[4],o[5],o[6]+r,o[7]+s],m,r,s),a=o[6],f=o[7];break;case"z":case"Z":e.closePath()}u=o}return m.translate(r,s)}var e={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},n=[/([MLHVCSQTAZmlhvcsqtaz])/g,/###/,/(\d)-/g,/\s|,|###/],s={},o={},u=Array.prototype.join,a;return{parse:r,render:c}}(),t.canvas.marks=function(){function u(e,n){var r=n.x||0,i=n.y||0,s=n.innerRadius||0,o=n.outerRadius||0,u=(n.startAngle||0)-Math.PI/2,a=(n.endAngle||0)-Math.PI/2;return e.beginPath(),s===0?e.moveTo(r,i):e.arc(r,i,s,u,a,0),e.arc(r,i,o,a,u,1),e.closePath(),(new t.Bounds).set(r-o,i-o,r+o,i+o)}function a(e,t){return r(e,n(t.path),t.x,t.y)}function f(e,n){e.beginPath();var r=n.size!=undefined?n.size:100,o=n.x,u=n.y,a,f,l,c,h=new t.Bounds;if(n.shape==undefined||n.shape==="circle")return a=Math.sqrt(r/Math.PI),e.arc(o,u,a,0,2*Math.PI,0),e.closePath(),h.set(o-a,u-a,o+a,u+a);switch(n.shape){case"cross":a=Math.sqrt(r/5)/2,f=3*a,e.moveTo(o-f,u-a),e.lineTo(o-a,u-a),e.lineTo(o-a,u-f),e.lineTo(o+a,u-f),e.lineTo(o+a,u-a),e.lineTo(o+f,u-a),e.lineTo(o+f,u+a),e.lineTo(o+a,u+a),e.lineTo(o+a,u+f),e.lineTo(o-a,u+f),e.lineTo(o-a,u+a),e.lineTo(o-f,u+a),h.set(o-f,u-f,o+u,u+f);break;case"diamond":c=Math.sqrt(r/(2*s)),l=c*s,e.moveTo(o,u-c),e.lineTo(o+l,u),e.lineTo(o,u+c),e.lineTo(o-l,u),h.set(o-l,u-c,o+l,u+c);break;case"square":f=Math.sqrt(r),a=f/2,e.rect(o-a,u-a,f,f),h.set(o-a,u-a,o+a,u+a);break;case"triangle-down":l=Math.sqrt(r/i),c=l*i/2,e.moveTo(o,u+c),e.lineTo(o+l,u-c),e.lineTo(o-l,u-c),h.set(o-l,u-c,o+l,u+c);break;case"triangle-up":l=Math.sqrt(r/i),c=l*i/2,e.moveTo(o,u-c),e.lineTo(o+l,u+c),e.lineTo(o-l,u+c),h.set(o-l,u-c,o+l,u+c)}return e.closePath(),h}function l(t,i){var s=e.svg.area().x(function(e){return e.x}).y1(function(e){return e.y}).y0(function(e){return e.y+e.height}),o=i[0];return o.interpolate&&s.interpolate(o.interpolate),o.tension!=undefined&&s.tension(o.tension),r(t,n(s(i)))}function c(t,i){var s=e.svg.line().x(function(e){return e.x}).y(function(e){return e.y}),o=i[0];return o.interpolate&&s.interpolate(o.interpolate),o.tension!=undefined&&s.tension(o.tension),r(t,n(s(i)))}function h(e,t,n,r){var i=n.fill,s=n.stroke,o,u,a;n.bounds=e(t,r),o=n.opacity==null?1:n.opacity;if(o==0||!i&&!s)return;i&&(t.globalAlpha=o*(n.fillOpacity==null?1:n.fillOpacity),t.fillStyle=i,t.fill()),s&&(a=(a=n.strokeWidth)!=undefined?a:1,a>0&&(t.globalAlpha=o*(n.strokeOpacity==null?1:n.strokeOpacity),t.strokeStyle=s,t.lineWidth=a,t.lineCap=(u=n.strokeCap)!=undefined?u:"butt",t.stroke(),n.bounds.expand(a)))}function p(e,t,n,r){var i,s,o;for(i=0,s=n.items.length;i<s;++i){o=n.items[i];if(r&&!r.intersects(o.bounds))continue;h(e,t,o,o)}}function d(e,n,r){if(!n.items.length)return;var i=n.items,s,o,u,a,f,l,c,h;for(var p=0,d=i.length;p<d;++p){s=i[p];if(r&&!r.intersects(s.bounds))continue;c=s.x||0,h=s.y||0,s.bounds=(s.bounds||new t.Bounds).set(c,h,c+s.width,h+s.height),a=s.opacity==null?1:s.opacity;if(a==0)return;if(o=s.fill)e.globalAlpha=a*(s.fillOpacity==null?1:s.fillOpacity),e.fillStyle=o,e.fillRect(c,h,s.width,s.height);if(u=s.stroke)l=(l=s.strokeWidth)!=undefined?l:1,l>0&&(e.globalAlpha=a*(s.strokeOpacity==null?1:s.strokeOpacity),e.strokeStyle=u,e.lineWidth=l,e.lineCap=(f=s.strokeCap)!=undefined?f:"butt",e.strokeRect(c,h,s.width,s.height),s.bounds.expand(l))}}function v(e,n,r){if(!n.items.length)return;var i=n.items,s,o,u,a,f,l,c,h,p;for(var d=0,v=i.length;d<v;++d){s=i[d];if(r&&!r.intersects(s.bounds))continue;l=s.x||0,c=s.y||0,h=s.x2!==undefined?s.x2:l,p=s.y2!==undefined?s.y2:c,s.bounds=(s.bounds||new t.Bounds).set(l,c,h,p),u=s.opacity==null?1:s.opacity;if(u==0)return;if(o=s.stroke)f=(f=s.strokeWidth)!=undefined?f:1,f>0&&(e.globalAlpha=u*(s.strokeOpacity==null?1:s.strokeOpacity),e.strokeStyle=o,e.lineWidth=f,e.lineCap=(a=s.strokeCap)!=undefined?a:"butt",e.beginPath(),e.moveTo(l,c),e.lineTo(h,p),e.stroke(),s.bounds.expand(f))}}function m(e,n,r){if(!n.items.length)return;var i=this,s=n.items,o;for(var u=0,a=s.length;u<a;++u){o=s[u];if(r&&!r.intersects(o.bounds))continue;if(!o.image||o.image.url!==o.url)o.image=i.loadImage(o.url),o.image.url=o.url;var f,l,c,h,p;c=o.width||o.image&&o.image.width||0,h=o.height||o.image&&o.image.height||0,f=o.x-(o.align==="center"?c/2:o.align==="right"?c:0),l=o.y-(o.baseline==="middle"?h/2:o.baseline==="bottom"?h:0),o.bounds=(o.bounds||new t.Bounds).set(f,l,f+c,l+h),o.image.loaded&&(e.globalAlpha=(p=o.opacity)!=undefined?p:1,e.drawImage(o.image,f,l,c,h))}}function g(e){return(e.fontStyle?e.fontStyle+" ":"")+(e.fontVariant?e.fontVariant+" ":"")+(e.fontWeight?e.fontWeight+" ":"")+(e.fontSize!=undefined?e.fontSize+"px ":"11px ")+(e.font||"sans-serif")}function b(e,n,r){if(!n.items.length)return;var i=n.items,s,o,u,a,f,l,c,h;for(var p=0,d=i.length;p<d;++p){s=i[p];if(r&&!r.intersects(s.bounds))continue;e.font=g(s),e.textAlign=s.align||"left",e.textBaseline=s.baseline||"alphabetic",s.bounds=w(e,s,s.bounds||new t.Bounds).expand(1),a=s.opacity==null?1:s.opacity;if(a==0)return;s.angle?(e.save(),e.translate(s.x,s.y),e.rotate(s.angle*Math.PI/180),x=s.dx||0,y=s.dy||0):(x=s.x+(s.dx||0),y=s.y+(s.dy||0));if(o=s.fill)e.globalAlpha=a*(s.fillOpacity==null?1:s.fillOpacity),e.fillStyle=o,e.fillText(s.text,x,y);if(u=s.stroke)f=(f=s.strokeWidth)!=undefined?f:1,f>0&&(e.globalAlpha=a*(s.strokeOpacity==null?1:s.strokeOpacity),e.strokeStyle=u,e.lineWidth=f,e.strokeText(s.text,x,y));s.angle&&e.restore()}}function w(e,t,n,r){var i=t.x+(t.dx||0),s=t.y+(t.dy||0),o=e.measureText(t.text).width,u=t.fontSize,a=t.align,f=t.baseline,l,c,h,p,d;return a==="center"?i-=o/2:a==="right"&&(i-=o),f==="top"?s+=u/5:f==="bottom"?s-=u:f==="middle"?s=s-u/2+u/10:s-=4*u/5,n.set(i,s,i+o,s+u),!r&&t.angle&&n.rotate(t.angle*Math.PI/180,t.x,t.y),n}function E(e){return function(t,n,r){p(e,t,n,r)}}function S(e){return function(t,n,r){if(!n.items.length)return;if(r&&!r.intersects(n.items[0].bounds))return;h(e,t,n.items[0],n.items)}}function T(e,t,n){if(!t.items.length)return;var r=t.items,i,s,o=this,u,a,f,l,c,h;d(e,t,n);for(f=0,l=r.length;f<l;++f){i=r[f],s=i.axisItems||[],u=i.x||0,a=i.y||0,e.save(),e.translate(u,a),n&&n.translate(-u,-a);for(c=0,h=s.length;c<h;++c)s[c].def.layer==="back"&&o.draw(e,s[c],n);for(c=0,h=i.items.length;c<h;++c)o.draw(e,i.items[c],n);for(c=0,h=s.length;c<h;++c)s[c].def.layer!=="back"&&o.draw(e,s[c],n);n&&n.translate(u,a),e.restore()}}function N(e,t,n,r,i,s){if(t.items.length===0||t.bounds&&!t.bounds.contains(i,s))return!1;var o=t.items,u,a,f,l,c,h=this;for(var p=0,d=o.length;p<d;++p){a=o[p],l=a.x||0,c=a.y||0,e.save(),e.translate(l,c);for(var v=0,m=a.items.length;v<m;++v){u=a.items[v];if(u.interactive===!1)continue;f=h.pick(u,n,r,i-l,s-c);if(f)return e.restore(),f}e.restore()}return t.interactive?C(M.rect,e,t,n,r,i,s):!1}function C(e,t,n,r,i,s,o){if(!n.items.length)return!1;var u,a,f;t._ratio!==1&&(r*=t._ratio,i*=t._ratio);for(f=n.items.length;--f>=0;){u=n.items[f],a=u.bounds;if(a&&!a.contains(s,o)||!a)continue;if(e(t,u,r,i,s,o))return u}return!1}function k(e,t,n,r,i,s){if(!t.items.length)return!1;var o=t.items,u,a,f,l,c,h,p,d;return a=o[0].bounds,a&&!a.contains(i,s)?!1:(e._ratio!==1&&(n*=e._ratio,r*=e._ratio),M.area(e,o,n,r)?o[0]:!1)}function L(e,t,n,r,i,s){return!1}function A(e,t,n,r,i,s){return!1}function O(e){return function(t,n,r,i,s,o){return C(e,t,n,r,i,s,o)}}function _(e,t,n,r,i,s){if(!t.fontSize)return!1;if(!t.angle)return!0;e.font=g(t);var u=w(e,t,o,!0),a=-t.angle*Math.PI/180,f=Math.cos(a),l=Math.sin(a),n=t.x,r=t.y,c=f*i-l*s+(n-n*f+r*l),h=l*i+f*s+(r-n*l-r*f);return u.contains(c,h)}var n=t.canvas.path.parse,r=t.canvas.path.render,i=Math.sqrt(3),s=Math.tan(30*Math.PI/180),o=new t.Bounds,M={text:_,rect:function(e,t,n,r){return!0},image:function(e,t,n,r){return!0},arc:function(e,t,n,r){return u(e,t),e.isPointInPath(n,r)},area:function(e,t,n,r){return l(e,t),e.isPointInPath(n,r)},path:function(e,t,n,r){return a(e,t),e.isPointInPath(n,r)},symbol:function(e,t,n,r){return f(e,t),e.isPointInPath(n,r)}};return{draw:{group:T,area:S(l),line:S(c),arc:E(u),path:E(a),symbol:E(f),rect:d,rule:v,text:b,image:m,drawOne:S,drawAll:E},pick:{group:N,area:k,line:L,arc:O(M.arc),path:O(M.path),symbol:O(M.symbol),rect:O(M.rect),rule:A,text:O(M.text),image:O(M.image),pickAll:C}}}(),t.canvas.Renderer=function(){function i(e,t){var n=window.devicePixelRatio||1,r=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,i=n/r;if(n!==r){var s=e.width,o=e.height;e.setAttribute("width",s*i),e.setAttribute("height",o*i),e.style.width=s+"px",e.style.height=o+"px"}return i}function s(e){var n=new t.Bounds(e.bounds);while((e=e.mark.group)!=null)n.translate(e.x||0,e.y||0);return n}function o(e){return e?t.array(e).reduce(function(e,t){return e.union(s(t))},new t.Bounds):null}function u(e,n){var r=null;return n&&(r=(new t.Bounds(n)).round(),e.beginPath(),e.rect(r.x1,r.y1,r.width(),r.height()),e.clip()),r}var n=function(){this._ctx=null,this._el=null,this._imgload=0},r=n.prototype;return r.initialize=function(t,n,r,s){this._el=t,this._width=n,this._height=r,this._padding=s;if(!t)return this;var o=e.select(t).selectAll("canvas.marks").data([1]);o.enter().append("canvas").attr("class","marks"),o.attr("width",n+s.left+s.right).attr("height",r+s.top+s.bottom);var u;return this._ctx=o.node().getContext("2d"),this._ctx._ratio=u=i(o.node(),this._ctx)||1,this._ctx.setTransform(u,0,0,u,u*s.left,u*s.top),this},r.context=function(e){return e?(this._ctx=e,this):this._ctx},r.element=function(){return this._el},r.pendingImages=function(){return this._imgload},r.render=function(e,t){var n=this._ctx,r=this._padding,i=this._width+r.left+r.right,s=this._height+r.top+r.bottom,a=null,f;this._scene=e,n.save(),a=u(n,o(t)),n.clearRect(-r.left,-r.top,i,s),this.draw(n,e,a),t&&(n.restore(),n.save(),f=u(n,o(t)),a.encloses(f)||(n.clearRect(-r.left,-r.top,i,s),this.draw(n,e,f))),n.restore(),this._scene=null},r.draw=function(e,n,r){var i=n.marktype,s=t.canvas.marks.draw[i];s.call(this,e,n,r)},r.renderAsync=function(e){var t=this;t._async_id&&clearTimeout(t._async_id),t._async_id=setTimeout(function(){t.render(e),delete t._async_id},50)},r.loadImage=function(e){var n=this,r=n._scene,i=null;return n._imgload+=1,t.config.isNode?(i=new(require("canvas").Image),t.data.load(e,function(e,r){if(e){t.error(e);return}i.src=r,i.loaded=!0,n._imgload-=1})):(i=new Image,i.onload=function(){t.log("LOAD IMAGE: "+e),i.loaded=!0,n._imgload-=1,n.renderAsync(r)},i.src=e),i},n}(),t.canvas.Handler=function(){function s(e){var t=e.indexOf(".");return t<0?e:e.slice(0,t)}var n=function(e,t){this._active=null,this._handlers={},e&&this.initialize(e),t&&this.model(t)},r=n.prototype;r.initialize=function(t,n,s){this._el=e.select(t).node(),this._canvas=e.select(t).select("canvas.marks").node(),this._padding=n,this._obj=s||null;var o=this._canvas,u=this;return i.forEach(function(e){o.addEventListener(e,function(t){r[e].call(u,t)})}),this},r.model=function(e){return arguments.length?(this._model=e,this):this._model},r.handlers=function(){var e=this._handlers;return t.keys(e).reduce(function(t,n){return e[n].reduce(function(e,t){return e.push(t),e},t)},[])};var i=["mousedown","mouseup","click","dblclick","wheel","keydown","keypress","keyup","mousewheel"];return i.forEach(function(e){r[e]=function(t){this.fire(e,t)}}),i.push("mousemove"),i.push("mouseout"),r.mousemove=function(e){var t=this._padding,n=e.target.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,s=this._active,o=this.pick(this._model.scene(),r,i,r-t.left,i-t.top);if(o===s){this.fire("mousemove",e);return}s&&this.fire("mouseout",e),this._active=o,o&&this.fire("mouseover",e)},r.mouseout=function(e){this._active&&this.fire("mouseout",e),this._active=null},r.DOMMouseScroll=function(e){this.fire("mousewheel",e)},r.fire=function(e,t){var n=this._active,r=this._handlers[e];if(n&&r)for(var i=0,s=r.length;i<s;++i)r[i].handler.call(this._obj,t,n)},r.on=function(e,t){var n=s(e),r=this._handlers;return r=r[n]||(r[n]=[]),r.push({type:e,handler:t}),this},r.off=function(e,t){var n=s(e),r=this._handlers[n];if(!r)return;for(var i=r.length;--i>=0;){if(r[i].type!==e)continue;(!t||r[i].handler===t)&&r.splice(i,1)}return this},r.context=function(){return this._canvas.getContext("2d")},r.pick=function(e,n,r,i,s){var o=this.context(),u=e.marktype,a=t.canvas.marks.pick[u];return a.call(this,o,e,n,r,i,s)},n}(),t.svg={},t.svg.marks=function(){function n(e){return e.x||0}function r(e){return e.y||0}function i(e){return e.y+e.height||0}function s(e){return e.key}function o(e){return e.size==null?100:e.size}function u(e){return e.shape||"circle"}function v(e){var t=e.mark?e:e[0],n,r,i,s,o;for(n=0,r=d.length;n<r;++n)i=d[n],s=p[i],o=t[i],o==null?s==="fill"?this.style.setProperty(s,"none",null):this.style.removeProperty(s):this.style.setProperty(s,o,null)}function m(e){var t=e.x||0,n=e.y||0;this.setAttribute("transform","translate("+t+","+n+")"),this.setAttribute("d",a(e))}function g(e){var t=e[0];f.interpolate(t.interpolate||"linear").tension(t.tension==undefined?.7:t.tension),this.setAttribute("d",f(e))}function y(e){var t=e[0];l.interpolate(t.interpolate||"linear").tension(t.tension==undefined?.7:t.tension),this.setAttribute("d",l(e))}function b(e){var t=e.x||0,n=e.y||0;this.setAttribute("transform","translate("+t+","+n+")"),this.setAttribute("d",e.path)}function w(e){this.setAttribute("x",e.x||0),this.setAttribute("y",e.y||0),this.setAttribute("width",e.width||0),this.setAttribute("height",e.height||0)}function E(e){var t=e.x||0,n=e.y||0;this.setAttribute("x1",t),this.setAttribute("y1",n),this.setAttribute("x2",e.x2!==undefined?e.x2:t),this.setAttribute("y2",e.y2!==undefined?e.y2:n)}function S(e){var t=e.x||0,n=e.y||0;this.setAttribute("transform","translate("+t+","+n+")"),this.setAttribute("d",c(e))}function x(e){var t=e.width||e.image&&e.image.width||0,n=e.height||e.image&&e.image.height||0,r=e.x-(e.align==="center"?t/2:e.align==="right"?t:0),i=e.y-(e.baseline==="middle"?n/2:e.baseline==="bottom"?n:0);this.setAttributeNS("http://www.w3.org/1999/xlink","href",e.url),this.setAttribute("x",r),this.setAttribute("y",i),this.setAttribute("width",t),this.setAttribute("height",n)}function T(e){return(e.fontStyle?e.fontStyle+" ":"")+(e.fontVariant?e.fontVariant+" ":"")+(e.fontWeight?e.fontWeight+" ":"")+(e.fontSize!=undefined?e.fontSize+"px ":"11px ")+(e.font||"sans-serif")}function N(e){var t=e.x||0,n=e.y||0,r=e.dx||0,i=e.dy||0,s=e.angle||0,o=h[e.align||"left"],u=e.baseline==="top"?".9em":e.baseline==="middle"?".35em":0;this.setAttribute("x",t+r),this.setAttribute("y",n+i),this.setAttribute("dy",i),this.setAttribute("text-anchor",o),s?this.setAttribute("transform","rotate("+s+" "+t+","+n+")"):this.removeAttribute("transform"),u?this.setAttribute("dy",u):this.removeAttribute("dy"),this.textContent=e.text,this.style.setProperty("font",T(e),null)}function C(e){var t=e.x||0,n=e.y||0;this.setAttribute("transform","translate("+t+","+n+")")}function k(e){var t=e.width||0,n=e.height||0;this.setAttribute("width",t),this.setAttribute("height",n)}function L(e,t,n){return function(r,i,s){O(r,i,s,"mark_",e,t,n)}}function O(t,n,r,i,s,o,u){var a=u?[n.items]:n.items,f=n.interactive===!1?"none":null,l=t.node().childNodes,c=s!=="g",h=l[r+1]?e.select(l[r+1]):t.append("g").attr("id","g"+ ++A),p="#"+h.attr("id"),d=p+" > "+s,m=h.selectAll(d).data(a),g=m.enter().append(s);return c?(h.style("pointer-events",f),g.each(function(e){(e.mark?e:e[0])._svg=this})):g.append("rect").attr("class","background").style("pointer-events",f),m.exit().remove(),m.each(o),c?m.each(v):h.selectAll(d+" > rect.background").each(k).each(v),h}function M(t,n,r,i){var s=O(t,n,r,i||"group_","g",C),o=s.node().childNodes,u=o.length,a,f,l;for(a=0;a<u;++a){var c=o[a].__data__.items,h=o[a].__data__.axisItems||[],p=e.select(o[a]);idx=0;for(f=0,l=h.length;f<l;++f)h[f].def.layer==="back"&&M.call(this,p,h[f],idx++,"axis_");for(f=0,l=c.length;f<l;++f)this.draw(p,c[f],idx++);for(f=0,l=h.length;f<l;++f)h[f].def.layer!=="back"&&M.call(this,p,h[f],idx++,"axis_")}}var a=e.svg.arc(),f=e.svg.area().x(n).y1(r).y0(i),l=e.svg.line().x(n).y(r),c=e.svg.symbol().type(u).size(o),h={left:"start",center:"middle",right:"end"},p={fill:"fill",fillOpacity:"fill-opacity",stroke:"stroke",strokeWidth:"stroke-width",strokeOpacity:"stroke-opacity",opacity:"opacity"},d=t.keys(p),A=0;return{update:{group:w,area:g,line:y,arc:m,path:b,symbol:S,rect:w,rule:E,text:N,image:x},nested:{area:!0,line:!0},style:v,draw:{group:M,area:L("path",g,!0),line:L("path",y,!0),arc:L("path",m),path:L("path",b),symbol:L("path",S),rect:L("rect",w),rule:L("line",E),text:L("text",N),image:L("image",x),draw:L}}}(),t.svg.Renderer=function(){var n=function(){this._ctx=null,this._el=null},r=n.prototype;return r.initialize=function(t,n,r,i){this._el=t,this._width=n,this._height=r,this._padding=i,e.select(t).select("svg.marks").remove();var s=e.select(t).append("svg").attr("class","marks").attr("width",n+i.left+i.right).attr("height",r+i.top+i.bottom);return this._ctx=s.append("g").attr("transform","translate("+i.left+","+i.top+")"),this},r.context=function(){return this._ctx},r.element=function(){return this._el},r.render=function(e,n){n?this.renderItems(t.array(n)):this.draw(this._ctx,e,0)},r.renderItems=function(e){var n,r,i,s,o,u,a=t.svg.marks;for(o=0,u=e.length;o<u;++o)n=e[o],r=n._svg,i=n.mark.marktype,n=a.nested[i]?n.mark.items:n,a.update[i].call(r,n),a.style.call(r,n)},r.draw=function(e,n,r){var i=n.marktype,s=t.svg.marks.draw[i];s.call(this,e,n,r)},n}(),t.svg.Handler=function(){function r(e){var t=this;return function(n){var r=n.target,i=r.__data__;i&&(i=i.mark?i:i[0],e.call(t._obj,n,i))}}function i(e){var t=e.indexOf(".");return t<0?e:e.slice(0,t)}var n=function(e,t){this._active=null,this._handlers={},e&&this.initialize(e),t&&this.model(t)},s=n.prototype;return s.initialize=function(t,n,r){return this._el=e.select(t).node(),this._svg=e.select(t).select("svg.marks").node(),this._padding=n,this._obj=r||null,this},s.model=function(e){return arguments.length?(this._model=e,this):this._model},s.handlers=function(){var e=this._handlers;return t.keys(e).reduce(function(t,n){return e[n].reduce(function(e,t){return e.push(t),e},t)},[])},s.on=function(t,n){var s=i(t),o=this._handlers,u=e.select(this._svg).node(),a={type:t,handler:n,svg:r.call(this,n)};return o=o[s]||(o[s]=[]),o.push(a),u.addEventListener(s,a.svg),this},s.off=function(t,n){var r=i(t),s=this._handlers[r],o=e.select(this._svg).node();if(!s)return;for(var u=s.length;--u>=0;){if(s[u].type!==t)continue;if(!n||s[u].handler===n)o.removeEventListener(r,s[u].svg),s.splice(u,1)}return this},n}(),t.data={},t.data.ingest=function(e,t){return{data:e,index:t}},t.data.mapper=function(e){return function(t){return t.forEach(e),t}},t.data.size=function(e,n){return e=t.isArray(e)?e:[0,e],e=e.map(function(e){return typeof e=="string"?n[e]:e}),e},t.data.load=function(e,n){if(t.config.isNode){var r=o(e)?e:t.config.baseURL+e,i=u(r)?f:l;i(r,n)}else a(e,n)};var i=/^[A-Za-z]+\:\/\//,s="file://";t.data.read=function(){function i(e,t){var r=t&&t.type||"json";return e=n[r](e,t),t&&t.parse&&s(e,t.parse),e}function s(e,n){var i=t.keys(n),s=i.map(function(e){return r[n[e]]}),o,u,a,f,l;for(u=0,f=e.length;u<f;++u){o=e[u];for(a=0,l=i.length;a<l;++a)o[i[a]]=s[a](o[i[a]])}}var n={},r={number:t.number,"boolean":t.boolean,date:Date.parse};return n.json=function(e,n){var r=JSON.parse(e);return n&&n.property&&(r=t.accessor(n.property)(r)),r},n.csv=function(t,n){var r=e.csv.parse(t);return r},n.tsv=function(t,n){var r=e.tsv.parse(t);return r},i.formats=n,i.parse=s,i}(),t.data.array=function(){function n(t){return t.map(function(t){var n=[];for(var r=0,i=e.length;r<i;++r)n.push(e[r](t));return n})}var e=[];return n.fields=function(r){return e=t.array(r).map(t.accessor),n},n},t.data.copy=function(){var e=t.accessor("data"),n=[],r=null,i=t.data.mapper(function(t){var i=e(t),s,o,u=n,a=r||n;for(s=0,o=n.length;s<o;++s)t[a[s]]=i[n[s]];return t});return i.from=function(n){return e=t.accessor(n),i},i.fields=function(e){return n=t.array(e),i},i.as=function(e){return r=t.array(e),i},i},t.data.facet=function(){function r(t){var r={key:"",keys:[],values:[]},i={},s=r.values,o,u,a,f,l,c,h,p,d;if(e.length===0)return s.push(o={key:"",keys:[],index:0,values:n?t:t.slice()}),n&&o.values.sort(n),r;for(l=0,f=t.length;l<f;++l){for(h=0,u=[],a="";h<e.length;++h)p=e[h](t[l]),u.push(p),a+=(h>0?"|":"")+String(p);o=i[a],o===undefined&&s.push(o=i[a]={key:a,keys:u,index:s.length,values:[]}),o.values.push(t[l])}if(n)for(l=0,f=s.length;l<f;++l)s[l].values.sort(n);return r}var e=[],n=null;return r.keys=function(n){return e=t.array(n).map(t.accessor),r},r.sort=function(e){return n=t.comparator(e),r},r},t.data.filter=function(){function n(t){return e?t.filter(e):t}var e=null;return n.test=function(r){return e=t.isFunction(r)?r:t.parse.expr(r),n},n},t.data.fold=function(){function i(t){var i=[],s,o,u,a,f=e.length;for(o=0,a=t.length;o<a;++o){s=t[o];for(u=0;u<f;++u){var l={index:i.length,data:s.data};l[r.key]=e[u],l[r.value]=n[u](s),i.push(l)}}return i}var e=[],n=[],r={key:"key",value:"value"};return i.fields=function(r){return e=t.array(r),n=e.map(t.accessor),i},i.output=function(e){return t.keys(r).forEach(function(t){e[t]!==undefined&&(r[t]=e[t])}),i},i},t.data.force=function(){function l(e,i,s){n.size(t.data.size(a,s)).nodes(e),r&&i[r]&&n.links(i[r]),n.start();for(var o=0;o<u;++o)n.tick();return n.stop(),e}var n=e.layout.force(),r=null,i=20,s=1,o=-30,u=500,a=["width","height"],f=["friction","theta","gravity","alpha"];return l.links=function(e){return r=e,l},l.size=function(e){return a=e,l},l.linkDistance=function(e){return i=typeof e=="number"?e:t.accessor(e),n.linkDistance(i),l},l.linkStrength=function(e){return s=typeof e=="number"?e:t.accessor(e),n.linkStrength(s),l},l.charge=function(e){return o=typeof e=="number"?e:t.accessor(e),n.charge(o),l},l.iterations=function(e){return u=e,l},f.forEach(function(e){l[e]=function(
t){return n[e](t),l}}),l},t.data.formula=function(){return function(){var e=null,n=t.identity,r=t.data.mapper(function(t){return e&&(t[e]=n.call(null,t)),t});return r.field=function(t){return e=t,r},r.expr=function(e){return n=t.isFunction(e)?e:t.parse.expr(e),r},r}}(),t.data.geo=function(){function r(){var r={},i="mercator",s=e.geo[i](),o=t.identity,u=t.identity,a={x:"x",y:"y"},f=t.data.mapper(function(e){var t=[u(e),o(e)],n=s(t);return e[a.x]=n[0],e[a.y]=n[1],e});return f.func=function(){return s},f.projection=function(t){if(i!==t){i=t,s=e.geo[i]();for(var n in r)s[n](r[n])}return f},n.forEach(function(e){f[e]=function(t){return r[e]=t,s[e](t),f}}),f.lon=function(e){return u=t.accessor(e),f},f.lat=function(e){return o=t.accessor(e),f},f.output=function(e){return t.keys(a).forEach(function(t){e[t]!==undefined&&(a[t]=e[t])}),e},f}var n=["center","scale","translate","rotate","precision","clipAngle"];return r.params=n,r}(),t.data.geopath=function(){var n=e.geo.path(),r="mercator",i=t.identity,s={},o={path:"path"},u=t.data.mapper(function(e){return e[o.path]=n(i(e)),e});return u.projection=function(t){if(r!==t){r=t;var i=e.geo[r]();for(var o in s)i[o](s[o]);n.projection(i)}return u},t.data.geo.params.forEach(function(e){u[e]=function(t){return s[e]=t,n.projection()[e](t),u}}),u.value=function(e){return i=t.accessor(e),u},u.output=function(e){return t.keys(o).forEach(function(t){e[t]!==undefined&&(o[t]=e[t])}),e},u},t.data.link=function(){function o(e){var t=n(e),i=r(e);return"M"+t.x+","+t.y+"L"+i.x+","+i.y}function u(e){var t=n(e),s=r(e),o=s.x-t.x,u=s.y-t.y,a=i*(o+u),f=i*(u-o);return"M"+t.x+","+t.y+"C"+(t.x+a)+","+(t.y+f)+" "+(s.x+f)+","+(s.y-a)+" "+s.x+","+s.y}function a(e){var t=n(e),i=r(e),s=(t.x+i.x)/2;return"M"+t.x+","+t.y+"C"+s+","+t.y+" "+s+","+i.y+" "+i.x+","+i.y}function f(e){var t=n(e),i=r(e),s=(t.y+i.y)/2;return"M"+t.x+","+t.y+"C"+t.x+","+s+" "+i.x+","+s+" "+i.x+","+i.y}function c(t){var n=l[e];return t.forEach(function(e){e[s.path]=n(e)}),t}var e="line",n=t.accessor("source"),r=t.accessor("target"),i=.2,s={path:"path"},l={line:o,curve:u,diagonal:a,diagonalX:a,diagonalY:f};return c.shape=function(t){return e=t,c},c.tension=function(e){return i=e,c},c.source=function(e){return n=t.accessor(e),c},c.target=function(e){return r=t.accessor(e),c},c.output=function(e){return t.keys(s).forEach(function(t){e[t]!==undefined&&(s[t]=e[t])}),c},c},t.data.pie=function(){function a(t){var n=t.map(function(e,t){return+r(e)}),a=i,f=(s-i)/e.sum(n),l=e.range(t.length);return o&&l.sort(function(e,t){return n[e]-n[t]}),l.forEach(function(e){var r;t[e].value=r=n[e],t[e][u.startAngle]=a,t[e][u.endAngle]=a+=r*f}),t}var n=function(){return 1},r=n,i=0,s=2*Math.PI,o=!1,u={startAngle:"startAngle",endAngle:"endAngle"};return a.sort=function(e){return o=e,a},a.value=function(e){return r=e?t.accessor(e):n,a},a.startAngle=function(e){return i=Math.PI*e/180,a},a.endAngle=function(e){return s=Math.PI*e/180,a},a.output=function(e){return t.keys(u).forEach(function(t){e[t]!==undefined&&(u[t]=e[t])}),a},a},t.data.sort=function(){function n(n){n=t.isArray(n)?n:n.values||[],n.sort(e);for(var r=0,i=n.length;r<i;++r)n[r].index=r;return n}var e=null;return n.by=function(r){return e=t.comparator(r),n},n},t.data.stack=function(){function u(e){var t=o.y0,s=o.y1;return n.x(r).y(i).out(function(e,n,r){e[t]=n,e[s]=r+n})(e.values)}var n=e.layout.stack().values(function(e){return e.values}),r=null,i=null,s=["offset","order"],o={y0:"y2",y1:"y"};return u.point=function(e){return r=t.accessor(e),u},u.height=function(e){return i=t.accessor(e),u},s.forEach(function(e){u[e]=function(t){return n[e](t),u}}),u.output=function(t){return e.keys(o).forEach(function(e){t[e]!==undefined&&(o[e]=t[e])}),u},u},t.data.stats=function(){function i(i){var s=+Infinity,o=-Infinity,u=0,a=0,f=0,l,c,h,p,d=(t.isArray(i)?i:i.values||[]).map(e);for(l=0,c=d.length;l<c;++l)h=d[l],h<s&&(s=h),h>o&&(o=h),u+=h,p=h-a,a+=p/(l+1),f+=p*(h-a);f/=c-1;var v=t.isArray(i)?{}:i;return n&&(d.sort(t.numcmp),l=d.length>>1,v[r.median]=d.length%2?d[l]:(d[l-1]+d[l])/2),v[r.count]=c,v[r.min]=s,v[r.max]=o,v[r.sum]=u,v[r.mean]=a,v[r.variance]=f,v[r.stdev]=Math.sqrt(f),v}function s(e){return(t.isArray(e)?[e]:e.values||[]).map(i)}var e=t.accessor("data"),n=!1,r={count:"count",min:"min",max:"max",sum:"sum",mean:"mean",variance:"variance",stdev:"stdev",median:"median"};return s.median=function(e){return n=e||!1,s},s.value=function(n){return e=t.accessor(n),s},s.output=function(e){return t.keys(r).forEach(function(t){e[t]!==undefined&&(r[t]=e[t])}),s},s},t.data.treemap=function(){function u(e,s,u){e=n.size(t.data.size(i,u)).value(r).nodes(e);var a=t.keys(o),f=a.length;return e.forEach(function(e){var t,n;for(var r=0;r<f;++r)t=a[r],t!==o[t]&&(n=e[t],delete e[t],e[o[t]]=n)}),e}var n=e.layout.treemap().children(function(e){return e.values}),r=t.accessor("data"),i=["width","height"],s=["round","sticky","ratio","padding"],o={x:"x",y:"y",dx:"width",dy:"height"};return u.size=function(e){return i=e,u},u.value=function(e){return r=t.accessor(e),u},s.forEach(function(e){u[e]=function(t){return n[e](t),u}}),u.output=function(e){return t.keys(o).forEach(function(t){e[t]!==undefined&&(o[t]=e[t])}),u},u},t.data.unique=function(){function r(r){return t.unique(r,e).map(function(e){var t={};return t[n]=e,t})}var e=null,n="field";return r.field=function(n){return e=t.accessor(n),r},r.as=function(e){return n=e,r},r},t.data.wordcloud=function(){function f(e,u,f){function l(r,i){var o=n.size(),u=o[0]/2,f=o[1]/2,l=t.keys(a),c,h,p,d,v,m=l.length;e.sort(function(e,t){return s(t)-s(e)});for(p=0,d=r.length;p<d;++p){h=e[p];for(v=0;v<m;++v)c=l[v],h[a[c]]=r[p][c],c==="x"&&(h[a.x]+=u),c==="y"&&(h[a.y]+=f)}}return n.size(t.data.size(i,f)).text(r).fontSize(s).rotate(o).words(e).on("end",l).start(),e}var n=e.layout.cloud().size([900,500]),r=t.accessor("data"),i=["width","height"],s=function(){return 14},o=function(){return 0},u=["font","fontStyle","fontWeight","padding"],a={x:"x",y:"y",size:"fontSize",font:"font",rotate:"angle"};return f.text=function(e){return r=t.accessor(e),f},f.size=function(e){return i=e,f},f.fontSize=function(e){return s=t.accessor(e),f},f.rotate=function(e){var n;return t.isObject(e)&&!Array.isArray(e)?e.random!==undefined?(n=(n=e.random)?t.array(n):[0],o=function(){return n[~~(Math.random()*n.length-1e-5)]}):e.alternate!==undefined&&(n=(n=e.alternate)?t.array(n):[0],o=function(e,t){return n[t%n.length]}):o=t.accessor(field),f},u.forEach(function(e){f[e]=function(t){return n[e](t),f}}),f.output=function(e){return t.keys(a).forEach(function(t){e[t]!==undefined&&(a[t]=e[t])}),f},f},t.data.zip=function(){function o(t,o){var u=o[e],a=u.length,f,l,c,h;s&&(h={},u.forEach(function(e){h[s(e)]=e}));for(l=0,c=t.length;l<c;++l)f=t[l],f[n]=h?h[r(f)]||i:u[l%a];return t}var e=null,n="zip",r=t.accessor("data"),i=undefined,s=null;return o["with"]=function(t){return e=t,o},o["default"]=function(e){return i=e,o},o.as=function(e){return n=e,o},o.key=function(e){return r=t.accessor(e),o},o.withKey=function(e){return s=t.accessor(e),o},o},t.parse={},t.parse.axes=function(){function r(e,n,r){(e||[]).forEach(function(e,s){n[s]=n[s]||t.scene.axis(),i(e,s,n[s],r)})}function i(r,i,s,o){r.scale!==undefined&&s.scale(o[r.scale]);var u=r.orient||n[r.type];s.orient(u),r.values!==undefined&&s.tickValues(r.values),r.format!==undefined&&s.tickFormat(e.format(r.format)),r.subdivide!==undefined&&s.tickSubdivide(r.subdivide),r.tickPadding!==undefined&&s.tickPadding(r.tickPadding);var a=[];if(r.tickSize!==undefined)for(var f=0;f<3;++f)a.push(r.tickSize);else{var l=t.config.axis.tickSize;a=[l,l,l]}r.tickSizeMajor!==undefined&&(a[0]=r.tickSizeMajor),r.tickSizeMinor!==undefined&&(a[1]=r.tickSizeMinor),r.tickSizeEnd!==undefined&&(a[2]=r.tickSizeEnd),a.length&&s.tickSize.apply(s,a);if(r.ticks!==undefined){var c=t.isArray(r.ticks)?r.ticks:[r.ticks];s.ticks.apply(s,c)}r.offset&&s.offset(r.offset),r.layer&&s.layer(r.layer),r.grid&&s.grid(r.grid);if(r.properties){var h=r.properties;h.ticks?(s.majorTickProperties(h.majorTicks?t.extend({},h.ticks,h.majorTicks):h.ticks),s.minorTickProperties(h.minorTicks?t.extend({},h.ticks,h.minorTicks):h.ticks)):(h.majorTicks&&s.majorTickProperties(h.majorTicks),h.minorTicks&&s.minorTickProperties(h.minorTicks)),h.labels&&s.tickLabelProperties(h.labels),h.grid&&s.gridLineProperties(h.grid),h.axis&&s.domainProperties(h.axis)}}var n={x:"bottom",y:"left",top:"top",bottom:"bottom",left:"left",right:"right"};return r}(),t.parse.data=function(e,n){function s(e){return function(s,o){s?t.error("LOADING FAILED: "+e.url):r.load[e.name]=t.data.read(o.toString(),e.format),--i===0&&n()}}var r={defs:e,load:{},flow:{},source:{}},i=0;return(e||[]).forEach(function(e){e.url&&(i+=1,t.data.load(e.url,s(e))),e.values&&(e.format&&e.format.parse&&t.data.read.parse(e.values,e.format.parse),r.load[e.name]=e.values);if(e.source){var n=r.source[e.source]||(r.source[e.source]=[]);n.push(e.name)}e.transform&&(r.flow[e.name]=t.parse.dataflow(e))}),i===0&&setTimeout(n,1),r},t.parse.dataflow=function(e){var n=(e.transform||[]).map(t.parse.transform);return n.length?function(e,t,r){return n.reduce(function(e,n){return n(e,t,r)},e)}:t.identity},t.parse.expr=function(){var e={E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2"},t={abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan"},n=/([\"\']|[\=\<\>\~\&\|\?\:\+\-\/\*\%\!\^\,\;\[\]\{\}\(\) ]+)/;return function(r){var i=r.split(n),s,o,u,a,f,l;for(f=0,l=0,u=0,a=i.length;u<a;++u){var s=i[u];if(s==="'"){l||(f=!f);continue}if(s==='"'){f||(l=!l);continue}if(l||f)continue;e[s]&&(i[u]=e[s]),t[s]&&(o=i[u+1])&&o[0]==="("&&(i[u]=t[s])}return Function("d","return ("+i.join("")+");")}}(),t.parse.mark=function(e){var n=e.properties,r=e.marks;t.keys(n).forEach(function(e){n[e]=t.parse.properties(n[e])}),e.delay&&(e.delay=t.parse.properties({delay:e.delay}));if(e.from){var i=e.from.data,s=t.parse.dataflow(e.from);e.from=function(e,n,r){var o=t.scene.data(i?e[i]:null,r);return s(o,e,n)}}return r&&(e.marks=r.map(t.parse.mark)),e},t.parse.marks=function(e,n,r){return{type:"group",width:n,height:r,axes:e.axes||[],scales:e.scales||[],marks:(e.marks||[]).map(t.parse.mark)}},t.parse.padding=function(e){if(t.isObject(e))return e;var n=t.isNumber(e)?e:20;return{top:n,left:n,right:n,bottom:n}},t.parse.properties=function(){function e(e){var r="",i=t.keys(e),s,o,u,a,f={};r+="var o = trans ? {} : item;\n";for(s=0,o=i.length;s<o;++s)a=e[u=i[s]],r+=s>0?"\n ":" ",r+="o."+u+" = "+n(a)+";",f[u]=!0;return f.x2&&(r+="\n if (o.x > o.x2) { var t = o.x; o.x = o.x2; o.x2 = t; };",r+="\n o.width = (o.x2 - o.x);"),f.y2&&(r+="\n if (o.y > o.y2) { var t = o.y; o.y = o.y2; o.y2 = t; };",r+="\n o.height = (o.y2 - o.y);"),r+="if (trans) trans.interpolate(item, o);",Function("item","group","trans",r)}function n(e){if(e==null)return null;var n=e.value!==undefined?t.str(e.value):"item.datum.data";e.group!==undefined&&(n="group."+e.group),e.field!==undefined&&(n="item.datum["+t.field(e.field).map(t.str).join("][")+"]");if(e.scale!==undefined){var r="group.scales['"+e.scale+"']";e.band?n=r+".rangeBand()":n=r+"("+n+")"}return"("+(e.mult?e.mult+" * ":"")+n+")"+(e.offset?" + "+e.offset:"")}return e}(),t.parse.scales=function(){function f(e,t,n,r){return(e||[]).reduce(function(e,t){var i=t.name,s=i+":prev";return e[i]=l(t,e[i],n,r),e[s]=e[s]||e[i],e},t||{})}function l(e,n,i,s){var o=c(e,n),u=o.type===r?h:p,a=d(e,s),f=t.values(s.datum);return u(e,o,a,i,f),o}function c(r,i){var s=r.type||n;if(!i||s!==i.type){var o=a[s]||e.scale[s];o||t.error("Unrecognized scale type: "+s),(i=o()).type=s,i.scaleName=r.name}return i}function h(e,n,r,i,s){var o,u,a,f;o=e.domain,t.isArray(o)?n.domain(o):t.isObject(o)&&(u=i[o.data]||s,a=t.accessor(o.field),n.domain(t.unique(u,a))),f=typeof r[0]=="string",f||r.length>2?n.range(r):e.points?n.rangePoints(r,e.padding||0):e.round||e.round===undefined?n.rangeRoundBands(r,e.padding||0):n.rangeBands(r,e.padding||0)}function p(n,r,u,a,f){var l,c,h;l=[null,null],n.domain!==undefined&&(t.isArray(n.domain)?l=n.domain.slice():t.isObject(n.domain)?(c=a[n.domain.data]||f,t.array(n.domain.field).forEach(function(n,r){n=t.accessor(n),l[0]=e.min([l[0],e.min(c,n)]),l[1]=e.max([l[1],e.max(c,n)])})):l=n.domain),n.domainMin!==undefined&&(t.isObject(n.domainMin)?(l[0]=null,c=a[n.domainMin.data]||f,t.array(n.domainMin.field).forEach(function(n,r){n=t.accessor(n),l[0]=e.min([l[0],e.min(c,n)])})):l[0]=n.domainMin),n.domainMax!==undefined&&(t.isObject(n.domainMax)?(l[1]=null,c=a[n.domainMax.data]||f,t.array(n.domainMax.field).forEach(function(n,r){n=t.accessor(n),l[1]=e.max([l[1],e.max(c,n)])})):l[1]=n.domainMax),n.type!==i&&n.type!==o&&(n.zero||n.zero===undefined)&&(l[0]=Math.min(0,l[0]),l[1]=Math.max(0,l[1])),r.domain(l),n.range=="height"&&(u=u.reverse()),r[n.round?"rangeRound":"range"](u),n.exponent&&n.type===s&&r.exponent(n.exponent),n.clamp&&r.clamp(!0),n.nice&&(n.type===o?(h=e.time[n.nice],h||t.error("Unrecognized interval: "+h),r.nice(h)):r.nice())}function d(e,n){var r=[null,null];if(e.range!==undefined)if(typeof e.range=="string")if(u[e.range])r=[0,n[e.range]];else{if(!t.config.range[e.range])return t.error("Unrecogized range: "+e.range),r;r=t.config.range[e.range]}else t.isArray(e.range)?r=e.range:r=[0,e.range];e.rangeMin!==undefined&&(r[0]=e.rangeMin),e.rangeMax!==undefined&&(r[1]=e.rangeMax);if(e.reverse!==undefined){var i=e.reverse;t.isObject(i)&&(i=t.accessor(i.field)(n.datum)),i&&(r=r.reverse())}return r}var n="linear",r="ordinal",i="log",s="pow",o="time",u={width:1,height:1},a={time:e.time.scale,utc:e.time.scale.utc};return f}(),t.parse.spec=function(n,r,i){function s(e){e=t.duplicate(e);var n=e.width||500,s=e.height||500,o=e.viewport||null,u={width:n,height:s,viewport:o,padding:t.parse.padding(e.padding),marks:t.parse.marks(e,n,s),data:t.parse.data(e.data,function(){r(a)})},a=i(u)}i=i||t.ViewFactory,t.isObject(n)?s(n):e.json(n,function(e,n){e?t.error(e):s(n)})},t.parse.transform=function(e){var n=t.data[e.type]();return t.keys(e).forEach(function(t){if(t==="type")return;n[t](e[t])}),n},t.scene={},t.scene.GROUP="group",t.scene.ENTER=0,t.scene.UPDATE=1,t.scene.EXIT=2,t.scene.DEFAULT_DATA={sentinel:1},t.scene.data=function(e,n){var r=t.scene.DEFAULT_DATA;return e=t.values(e||n||[r]),e===r&&(e=[r]),e},t.scene.Item=function(){function e(e){this.mark=e}var t=e.prototype;return t.hasPropertySet=function(e){var t=this.mark.def.properties;return t&&t[e]!=null},t.cousin=function(e,t){if(e===0)return this;e=e||-1;var n=this.mark,r=n.group,i=t==null?n.items.indexOf(this):t,s=r.items.indexOf(n)+e;return r.items[s].items[i]},t.sibling=function(e){if(e===0)return this;e=e||-1;var t=this.mark,n=t.items.indexOf(this)+e;return t.items[n]},t.remove=function(){var e=this,t=e.mark.items,n=t.indexOf(e);return n>=0&&(n===t.length-1?t.pop():t.splice(n,1)),e},e}(),t.scene.item=function(e){return new t.scene.Item(e)},t.scene.build=function(){function u(e,r,i,s){var o=t.scene.data(e.from?e.from(r,i,s):null,s);return i=a(e,i),i.items=f(e,o,i),c(e,i),e.type===n&&l(e,r,i),i}function a(e,t){return t=t||{},t.def=e,t.marktype=e.type,t.interactive=e.interactive!==!1,t}function f(e,n,o){var u=h(e.key),a=o.items||[],f=[],l={},c,p,d,v,m,g;for(c=0,d=a.length;c<d;++c)v=a[c],v.status=s,u&&(l[v.key]=v);for(c=0,d=n.length;c<d;++c)m=n[c],p=c,v=u?l[p=u(m)]:a[c],g=v?!1:(v=t.scene.item(o),!0),v.status=g?r:i,v.datum=m,v.key=p,f.push(v);for(c=0,d=a.length;c<d;++c)v=a[c],v.status===s&&(v.key=u?v.key:f.length,f.push(v));return f}function l(e,t,n){var r=n.items,i=e.marks,s,o,a,f,l,c;for(s=0,o=r.length;s<o;++s){c=r[s];if(c.scales)for(l in c.scales)l.indexOf(":prev")<0&&(c.scales[l+":prev"]=c.scales[l].copy());c.items=c.items||[];for(a=0,f=i.length;a<f;++a)c.items[a]=u(i[a],t,c.items[a],c.datum),c.items[a].group=c}}function c(t,n){t.duration&&(n.duration=t.duration),t.ease&&(n.ease=e.ease(t.ease));if(t.delay){var r=n.items,i=n.group,s=r.length,o;for(o=0;o<s;++o)t.delay.call(this,r[o],i)}}function h(e){return e?t.accessor(e):null}var n=t.scene.GROUP,r=t.scene.ENTER,i=t.scene.UPDATE,s=t.scene.EXIT,o={sentinel:1};return u}(),t.scene.encode=function(){function s(e,t,n,r,i){return r&&i?o.call(this,e,t,n,r,i):u.call(this,e,e,t,n,r),e}function o(e,n,r,i,s){s=t.array(s);var o,u,a,f,l,c;for(o=0,u=s.length;o<u;++o)a=s[o],f=a.mark.group||null,l=a.mark.def.properties,c=l&&l[i],c&&c.call(this,a,f,r)}function u(t,n,r,i,s){f.call(this,t,n.items,r,i,s),n.marktype===e&&a.call(this,n,r,t,i,s)}function a(e,n,r,i,s){var o,a,f,l,c,h,p,d,v;for(o=0,a=e.items.length;o<a;++o){c=e.items[o],h=c.scales||(c.scales=t.extend({},r.scales)),n.scales&&t.parse.scales(n.scales,h,this._data,c),n.axes&&(p=c.axes||(c.axes=[]),d=c.axisItems||(c.axisItems=[]),t.parse.axes(n.axes,p,c.scales),p.forEach(function(e,n){v=e.def(),d[n]=t.scene.build(v,this._data,d[n]),u.call(this,c,c.axisItems[n],v,i)}));for(f=0,l=c.items.length;f<l;++f)u.call(this,c,c.items[f],n.marks[f],i,s)}}function f(e,t,s,o,u){if(s.properties==null)return;var a=s.properties,f=a.enter,l=a.update,c=a.exit,h,p,d,v;if(u&&(v=a[u])){for(h=0,p=t.length;h<p;++h)v.call(this,t[h],e,o);return}for(h=0;h<t.length;++h)d=t[h],d.status===n&&(f&&f.call(this,d,e),d.status=r),d.status!==i&&l&&l.call(this,d,e,o),d.status===i&&(c&&o&&c.call(this,d,e,o),o||t[h--].remove())}var e=t.scene.GROUP,n=t.scene.ENTER,r=t.scene.UPDATE,i=t.scene.EXIT;return s}(),t.scene.Transition=function(){function n(t,n){this.duration=t||500,this.ease=n&&e.ease(n)||e.ease("cubic-in-out"),this.updates={next:null}}function i(e){var t=this.updates,n=t,r=n.next,i=this.duration,s,o,u,a,f,l,c=!0;for(;r!=null;n=r,r=n.next){s=r.item,o=s.delay||0,u=(e-o)/i;if(u<0){c=!1;continue}u>1&&(u=1),a=r.ease(u);for(f=0,l=r.length;f<l;++f)s[r[f].property]=r[f](a);u===1?(r.remove&&s.remove(),n.next=r.next,r=n):c=!1}return this.callback(),c}var r=n.prototype;return r.interpolate=function(t,n){var r,i,s,o,u=null;for(r in n)i=t[r],s=n[r],i!==s&&(o=e.interpolate(i,s),o.property=r,(u||(u=[])).push(o));return o&&(u.item=t,u.ease=t.mark.ease||this.ease,u.next=this.updates.next,this.updates.next=u),this},r.start=function(n){var r=this,s=r.updates,o=s.next;for(;o!=null;s=o,o=s.next)o.item.status===t.scene.EXIT&&(o.remove=!0);r.callback=n,e.timer(function(e){return i.call(r,e)})},n}(),t.scene.transition=function(e,n){return new t.scene.Transition(e,n)},t.scene.axis=function(){function _(e){var r,i,s;e.type==="ordinal"?(r={scale:e.scaleName,offset:.5+e.rangeBand()/2},i=r):(r={scale:e.scaleName,offset:.5},i={scale:e.scaleName+":prev",offset:.5}),s=v(e);var o=T(),c=T(),h=T(),p=N(),d=C();o.properties.enter.stroke={value:t.config.axis.gridColor},w(n,o,i,r,Infinity),w(n,c,i,r,u),w(n,h,i,r,a),b(n,p,i,r,u,l),E(n,d,s,f),t.extend(o.properties.update,x),t.extend(c.properties.update,L),t.extend(h.properties.update,A),t.extend(p.properties.update,k),t.extend(d.properties.update,O);var m=[o,c,h,p,d];return{type:"group",interactive:!1,properties:{update:S},marks:m.map(t.parse.mark)}}var e,n=c,r=0,i=null,s="front",o=!1,u=t.config.axis.tickSize,a=t.config.axis.tickSize,f=t.config.axis.tickSize,l=t.config.axis.padding,d=null,m=null,g=0,y=[t.config.axis.ticks],x={},k={},L={},A={},O={},M={};return M.def=function(){var u=i=_(e),a=d==null?e.ticks?e.ticks.apply(e,y):e.domain():d,f=p(e,a,g).map(t.data.ingest);a=a.map(t.data.ingest);var l=m==null?e.tickFormat?e.tickFormat.apply(e,y):String:m;return a.forEach(function(e){e.label=l(e.data)}),u.marks[0].from=function(){return o?a:[]},u.marks[1].from=function(){return a},u.marks[2].from=function(){return f},u.marks[3].from=u.marks[1].from,u.marks[4].from=function(){return[1]},u.offset=r,u.orient=n,u.layer=s,u},M.scale=function(t){return arguments.length?(e=t,M):e},M.orient=function(e){return arguments.length?(n=e in h?e+"":c,M):n},M.ticks=function(){return arguments.length?(y=arguments,M):y},M.tickValues=function(e){return arguments.length?(d=e,M):d},M.tickFormat=function(e){return arguments.length?(m=e,M):m},M.tickSize=function(e,t){if(!arguments.length)return u;var n=arguments.length-1;return u=+e,a=n>1?+t:u,f=n>0?+arguments[n]:u,M},M.tickPadding=function(e){return arguments.length?(l=+e,M):l},M.tickSubdivide=function(e){return arguments.length?(g=+e,M):g},M.offset=function(e){return arguments.length?(r=e,M):d},M.layer=function(e){return arguments.length?(s=e,M):s},M.grid=function(e){return arguments.length?(o=e,M):o},M.gridLineProperties=function(e){return arguments.length?(x=e,M):x},M.majorTickProperties=function(e){return arguments.length?(L=e,M):L},M.minorTickProperties=function(e){return arguments.length?(A=e,M):A},M.tickLabelProperties=function(e){return arguments.length?(k=e,M):k},M.domainProperties=function(e){return arguments.length?(O=e,M):O},M};var c="bottom",h={top:1,right:1,bottom:1,left:1},m={bottom:"center",top:"center",left:"right",right:"left"},g={bottom:"top",top:"bottom",left:"middle",right:"middle"};return t.Model=function(){function e(){this._defs=null,this._data={},this._scene=null}var n=e.prototype;return n.defs=function(e){return arguments.length?(this._defs=e,this):this._defs},n.data=function(e){if(!arguments.length)return this._data;var n=this._defs.data.flow||{},r=this._defs.data.defs.map(t.accessor("name")),i,s,o,u,a;for(i=0,o=r.length;i<o;++i){if(!e[u=r[i]])continue;this._data[u]=n[u]?n[u](e[u],this._data,this._defs.marks):e[u],a=this._defs.data.source[u]||[];for(s=0;s<a.length;++s)this._data[a[s]]=n[a[s]]?n[a[s]](this._data[u],this._data,this._defs.marks):this._data[u]}return this},n.width=function(e){return this._defs&&(this._defs.width=e),this._defs&&this._defs.marks&&(this._defs.marks.width=e),this._scene&&(this._scene.items[0].width=e),this},n.height=function(e){return this._defs&&(this._defs.height=e),this._defs&&this._defs.marks&&(this._defs.marks.height=e),this._scene&&(this._scene.items[0].height=e),this},n.scene=function(e){return arguments.length?(this._scene=e,this):this._scene},n.build=function(){var e=this,n=e._data,r=e._defs.marks;return e._scene=t.scene.build.call(e,r,n,e._scene),e._scene.items[0].width=r.width,e._scene.items[0].height=r.height,e._scene.interactive=!1,this},n.encode=function(e,n,r){var i=this,s=i._scene,o=i._defs;return t.scene.encode.call(i,s,o.marks,e,n,r),this},e}(),t.View=function(){var n=function(e,n,r){this._el=null,this._build=!1,this._model=new t.Model,this._width=n||500,this._height=r||500,this._padding={top:0,left:0,bottom:0,right:0},this._viewport=null,this._renderer=null,this._handler=null,this._io=t.canvas,e&&this.initialize(e)},r=n.prototype;return r.width=function(e){return arguments.length?(this._width!==e&&(this._width=e,this._el&&this.initialize(this._el.parentNode),this._model.width(e)),this):this._width},r.height=function(e){return arguments.length?(this._height!==e&&(this._height=e,this._el&&this.initialize(this._el.parentNode),this._model.height(this._height)),this):this._height},r.padding=function(e){return arguments.length?(this._padding!==e&&(this._padding=e,this._el&&this.initialize(this._el.parentNode)),this):this._padding},r.viewport=function(e){return arguments.length?(this._viewport!==e&&(this._viewport=e,this._el&&this.initialize(this._el.parentNode)),this):this._viewport},r.renderer=function(e){return arguments.length?(e==="canvas"&&(e=t.canvas),e==="svg"&&(e=t.svg),this._io!==e&&(this._io=e,this._renderer=null,this._el&&this.initialize(this._el.parentNode),this._build&&this.render()),this):this._io},r.defs=function(e){return arguments.length?(this._model.defs(e),this):this._model.defs()},r.data=function(e){if(!arguments.length)return this._model.data();var n=t.keys(e).reduce(function(n,r){return n[r]=e[r].map(t.data.ingest),n},{});return this._model.data(n),this._build=!1,this},r.model=function(e){return arguments.length?(this._model!==e&&(this._model=e,this._handler&&this._handler.model(e)),this):this._model},r.initialize=function(t){var n=this,r,i=n._width,s=n._height,o=n._padding;return e.select(t).select("div.vega").remove(),this._el=t=e.select(t).append("div").attr("class","vega").style("position","relative").node(),n._viewport&&e.select(t).style("width",(n._viewport[0]||i)+"px").style("height",(n._viewport[1]||s)+"px").style("overflow","auto"),n._renderer=(n._renderer||new this._io.Renderer).initialize(t,i,s,o),r=n._handler,n._handler=(new this._io.Handler).initialize(t,o,n).model(n._model),r&&r.handlers().forEach(function(e){n._handler.on(e.type,e.handler)}),this},r.render=function(e){return this._renderer.render(this._model.scene(),e),this},r.on=function(){return this._handler.on.apply(this._handler,arguments),this},r.off=function(){return this._handler.off.apply(this._handler,arguments),this},r.update=function(e){e=e||{};var n=this,r=e.duration?t.scene.transition(e.duration,e.ease):null;return n._build=n._build||(n._model.build(),!0),n._model.encode(r,e.props,e.items),r?r.start(function(e){n._renderer.render(n._model.scene(),e)}):n.render(e.items),n},n}(),t.ViewFactory=function(e){return function(n){n=n||{};var r=(new t.View).width(e.width).height(e.height).padding(e.padding).viewport(e.viewport).renderer(n.renderer||"canvas").defs(e);return e.data.load&&r.data(e.data.load),n.data&&r.data(n.data),n.el&&r.initialize(n.el),n.hover!==!1&&r.on("mouseover",function(e,t){t.hasPropertySet("hover")&&this.update({props:"hover",items:t})}).on("mouseout",function(e,t){t.hasPropertySet("hover")&&this.update({props:"update",items:t})}),r}},t.Spec=function(){var e=function(e){this.spec={width:500,height:500,padding:0,data:[],scales:[],axes:[],marks:[]},e&&t.extend(this.spec,e)},n=e.prototype;return n.width=function(e){return this.spec.width=e,this},n.height=function(e){return this.spec.height=e,this},n.padding=function(e){return this.spec.padding=e,this},n.viewport=function(e){return this.spec.viewport=e,this},n.data=function(e,n){return n?n.name=e:n=t.isString(e)?{name:e}:e,this.spec.data.push(n),this},n.scale=function(e,n){return n?n.name=e:n=t.isString(e)?{name:e}:e,this.spec.scales.push(n),this},n.axis=function(e){return this.spec.axes.push(e),this},n.mark=function(e,n){n?n.type=e:n={type:e},n.properties={},this.spec.marks.push(n);var r=this;return{from:function(e,r){return n.from=r?(r.data=e,r):t.isString(e)?{data:e}:e,this},prop:function(e,r){return n.properties[e]=t.keys(r).reduce(function(e,n){var i=r[n];return e[n]=t.isObject(i)?i:{value:i},e},{}),this},done:function(){return r}}},n.parse=function(e){t.parse.spec(this.spec,e)},n.json=function(){return this.spec},e}(),t.spec=function(e){return new t.Spec(e)},t.headless={},t.headless.View=function(){var n=function(e,n,r,i){this._canvas=null,this._type=i,this._el="body",this._build=!1,this._model=new t.Model,this._width=e||500,this._height=n||500,this._padding=r||{top:0,left:0,bottom:0,right:0},this._renderer=new t[i].Renderer,this.initialize()},r=n.prototype;return r.el=function(e){return arguments.length?(this._el!==e&&(this._el=e,this.initialize()),this):this._el},r.width=function(e){return arguments.length?(this._width!==e&&(this._width=e,this.initialize(),this._model.width(e)),this):this._width},r.height=function(e){return arguments.length?(this._height!==e&&(this._height=e,this.initialize(),this._model.height(this._height)),this):this._height},r.padding=function(e){return arguments.length?(this._padding!==e&&(this._padding=e,this.initialize()),this):this._padding},r.defs=function(e){return arguments.length?(this._model.defs(e),this):this._model.defs()},r.data=function(e){if(!arguments.length)return this._model.data();var n=t.keys(e).reduce(function(n,r){return n[r]=e[r].map(t.data.ingest),n},{});return this._model.data(n),this._build=!1,this},r.renderer=function(){return this._renderer},r.canvas=function(){return this._canvas},r.canvasAsync=function(e){function n(){t.pendingImages()===0?(this.render(),e(this._canvas)):setTimeout(n,10)}var t=this._renderer;t.pendingImages()>0?n():e(this._canvas)},r.svg=function(){if(this._type!=="svg")return null;var n=this._padding,r=this._width+(n?n.left+n.right:0),i=this._height+(n?n.top+n.bottom:0),s=e.select(this._el).select("svg").node().innerHTML.replace(/ href=/g," xlink:href=");return'<svg width="'+r+'" '+'height="'+i+'" '+t.config.svgNamespace+">"+s+"</svg>"},r.initialize=function(){var e=this._width,t=this._height,n=this._padding;return this._type==="svg"?this.initSVG(e,t,n):this.initCanvas(e,t,n),this},r.initCanvas=function(e,t,n){var r=require("canvas"),i=e+n.left+n.right,s=t+n.top+n.bottom,o=this._canvas=new r(i,s),u=o.getContext("2d");u.setTransform(1,0,0,1,n.left,n.top),this._renderer.initialize(null,e,t,n),this._renderer.context(u)},r.initSVG=function(e,t,n){var r=e+n.left+n.right,i=t+n.top+n.bottom;this._renderer.initialize(this._el,e,t,n)},r.render=function(e){return this._renderer.render(this._model.scene(),e),this},r.update=function(e){e=e||{};var t=this;return t._build=t._build||(t._model.build(),!0),t._model.encode(null,e.props,e.items),t.render(e.items),t},n}(),t.headless.View.Factory=function(e){return function(n){n=n||{};var r=e.width,i=e.height,s=e.padding,o=n.renderer||"canvas",u=(new t.headless.View(r,i,s,o)).defs(e);return e.data.load&&u.data(e.data.load),n.data&&u.data(n.data),u}},t.headless.render=function(e,n){function r(t){try{var r=t({data:e.data,renderer:e.renderer}).update();e.renderer==="svg"?n(null,{svg:r.svg()}):r.canvasAsync(function(e){n(null,{canvas:e})})}catch(i){n(i,null)}}t.parse.spec(e.spec,r,t.headless.View.Factory)},t}(d3);