Socket
Socket
Sign inDemoInstall

vega-scenegraph

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-scenegraph - npm Package Compare versions

Comparing version 2.0.0-beta.5 to 2.0.0-beta.6

src/ResourceLoader.js

4

build/vega-scenegraph.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-loader"),require("d3-shape"),require("d3-path")):"function"==typeof define&&define.amd?define(["exports","vega-loader","d3-shape","d3-path"],e):e(t.vega=t.vega||{},t.vega,t.d3,t.d3)}(this,function(t,e,n,i){"use strict";function r(t){this.clear(),t&&this.union(t)}function o(t){this.mark=t,this.bounds=this.bounds||new r,this.bounds_prev=this.bounds_prev||new r}function a(t){o.call(this,t),this.items=this.items||[]}function s(t){this._pending=0,this._loader=t||e.loader()}function u(t,e,n){var i=_e.hasOwnProperty(t)&&_e[t],r=null;return i&&(r=i.curve||i[e||"vertical"],i.tension&&null!=n&&(r=r[i.tension](n))),r}function l(t,e,n,i,r,o,a,s,u){var l=Te.call(arguments);if(ke[l])return ke[l];var h=a*(Math.PI/180),c=Math.sin(h),f=Math.cos(h);n=Math.abs(n),i=Math.abs(i);var d=f*(s-t)*.5+c*(u-e)*.5,v=f*(u-e)*.5-c*(s-t)*.5,g=d*d/(n*n)+v*v/(i*i);g>1&&(g=Math.sqrt(g),n*=g,i*=g);var p=f/n,y=c/n,_=-c/i,m=f/i,x=p*s+y*u,b=_*s+m*u,k=p*t+y*e,w=_*t+m*e,T=(k-x)*(k-x)+(w-b)*(w-b),M=1/T-.25;M<0&&(M=0);var P=Math.sqrt(M);o==r&&(P=-P);var A=.5*(x+k)-P*(w-b),z=.5*(b+w)+P*(k-x),C=Math.atan2(b-z,x-A),S=Math.atan2(w-z,k-A),I=S-C;I<0&&1===o?I+=2*Math.PI:I>0&&0===o&&(I-=2*Math.PI);for(var q=Math.ceil(Math.abs(I/(.5*Math.PI+.001))),O=[],N=0;N<q;++N){var R=C+N*I/q,D=C+(N+1)*I/q;O[N]=[A,z,R,D,n,i,c,f]}return ke[l]=O}function h(t){var e=Te.call(t);if(we[e])return we[e];var n=t[0],i=t[1],r=t[2],o=t[3],a=t[4],s=t[5],u=t[6],l=t[7],h=l*a,c=-u*s,f=u*a,d=l*s,v=Math.cos(r),g=Math.sin(r),p=Math.cos(o),y=Math.sin(o),_=.5*(o-r),m=Math.sin(.5*_),x=8/3*m*m/Math.sin(_),b=n+v-x*g,k=i+g+x*v,w=n+p,T=i+y,M=w+x*y,P=T-x*p;return we[e]=[h*b+c*k,f*b+d*k,h*M+c*P,f*M+d*P,h*w+c*T,f*w+d*T]}function c(t,e){var n=Me[0]=t[0];if("a"===n||"A"===n)Me[1]=e*t[1],Me[2]=e*t[2],Me[6]=e*t[6],Me[7]=e*t[7];else for(var i=1,r=t.length;i<r;++i)Me[i]=e*t[i];return Me}function f(t,e,n,i){for(var r=l(i[5],i[6],i[0],i[1],i[3],i[4],i[2],e,n),o=0;o<r.length;++o){var a=h(r[o]);t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5])}}function d(t){return Ce.hasOwnProperty(t)?Ce[t]:v(t)}function v(t){if(!Se.hasOwnProperty(t)){var e=be(t);Se[t]={draw:function(t,n){Pe(t,e,0,0,Math.sqrt(n))}}}return Se[t]}function g(t){return t.x}function p(t){return t.y}function y(t){return t.width}function _(t){return t.height}function m(t){return function(){return t}}function x(t){return t.x||0}function b(t){return t.y||0}function k(t){return t.width||0}function w(t){return t.width||t.height||1}function T(t){return t.height||0}function M(t){return(t.x||0)+(t.width||0)}function P(t){return(t.y||0)+(t.height||0)}function A(t){return t.cornerRadius||0}function z(t){return t.padAngle||0}function C(t){return!(t.defined===!1)}function S(t){return null==t.size?64:t.size}function I(t){return d(t.shape||"circle")}function q(t,e){return Ne.context(t)(e)}function O(t,e){var n=e[0],i=n.interpolate||"linear";return("trail"===i?Ee:("horizontal"===n.orient?De:Re).curve(u(i,n.orient,n.tension))).context(t)(e)}function N(t,e){return(e.mark.shape||e.shape).context(t)(e)}function R(t,e){var n=e[0],i=n.interpolate||"linear";return Le.curve(u(i,n.orient,n.tension)).context(t)(e)}function D(t,e,n,i){return We.context(t)(e,n,i)}function L(t,e){return Ge.context(t)(e)}function E(t){return ye=t,E}function W(){}function G(t,e){ye.add(t,e)}function V(t,e){return t.zindex-e.zindex||t.index-e.index}function j(t){if(!t.zdirty)return t.zitems;var e,n,i,r=t.items,o=[];for(n=0,i=r.length;n<i;++n)e=r[n],e.index=n,e.zindex&&o.push(e);return t.zdirty=!1,t.zitems=o.sort(V)}function B(t,e){var n,i,r=t.items;if(r&&r.length){var o=j(t);if(o&&o.length){for(n=0,i=r.length;n<i;++n)r[n].zindex||e(r[n]);r=o}for(n=0,i=r.length;n<i;++n)e(r[n])}}function H(t,e){var n,i,r=t.items;if(!r||!r.length)return null;var o=j(t);for(o&&o.length&&(r=o),i=r.length;--i>=0;)if(n=e(r[i]))return n;if(r===o)for(r=t.items,i=r.length;--i>=0;)if(!r[i].zindex&&(n=e(r[i])))return n;return null}function J(t){return function(e,n,i){B(n,function(n){i&&!i.intersects(n.bounds)||U(t,e,n,n)})}}function X(t){return function(e,n,i){!n.items.length||i&&!i.intersects(n.bounds)||U(t,e,n.items[0],n.items)}}function U(t,e,n,i){var r=null==n.opacity?1:n.opacity;0!==r&&(t(e,i)||(n.fill&&Ue(e,n,r)&&e.fill(),n.stroke&&$e(e,n,r)&&e.stroke()))}function Q(t){return t||(t=Ye),function(e,n,i,r,o,a){return e.pixelRatio>1&&(i*=e.pixelRatio,r*=e.pixelRatio),H(n,function(n){var s=n.bounds;if((!s||s.contains(o,a))&&s)return t(e,n,i,r,o,a)?n:void 0})}}function $(t,e){return function(n,i,r,o){var a,s,u=Array.isArray(i)?i[0]:i,l=null==e?u.fill:e,h=u.stroke&&n.isPointInStroke;return h&&(a=u.strokeWidth,s=u.strokeCap,n.lineWidth=null!=a?a:1,n.lineCap=null!=s?s:"butt"),!t(n,i)&&(l&&n.isPointInPath(r,o)||h&&n.isPointInStroke(r,o))}}function Y(t){return Q($(t))}function Z(t,e,n){var i,r,o=null;t("transform",Fe(e)),e.clip&&(i=n._defs,o=e.clip_id||(e.clip_id="clip"+i.clip_id++),r=i.clipping[o]||(i.clipping[o]={id:o}),r.width=e.width||0,r.height=e.height||0),t("clip-path",o?"url(#"+o+")":null)}function F(t,e){var n=e.stroke?.5:0;t("class","background"),t("d",D(null,e,n,n))}function K(t,e){if(!e.clip&&e.items)for(var n=e.items,i=0,r=n.length;i<r;++i)t.union(n[i].bounds);return(e.clip||e.width||e.height)&&Ve(t.add(0,0).add(e.width||0,e.height||0),e),t.translate(e.x||0,e.y||0)}function tt(t,e,n){var i=this;B(e,function(e){var r,o,a=e.x||0,s=e.y||0,u=e.width||0,l=e.height||0;t.save(),t.translate(a,s),(e.stroke||e.fill)&&(o=null==e.opacity?1:e.opacity,o>0&&(t.beginPath(),r=e.stroke?.5:0,D(t,e,r,r),e.fill&&Ue(t,e,o)&&t.fill(),e.stroke&&$e(t,e,o)&&t.stroke())),e.clip&&(t.beginPath(),t.rect(0,0,u,l),t.clip()),n&&n.translate(-a,-s),B(e,function(e){i.draw(t,e,n)}),n&&n.translate(a,s),t.restore()})}function et(t,e,n,i,r,o){if(e.bounds&&!e.bounds.contains(r,o)||!e.items)return null;var a=this;return H(e,function(s){var u,l,h,c;if(c=s.bounds,!c||c.contains(r,o))return l=s.x||0,h=s.y||0,t.save(),t.translate(l,h),l=r-l,h=o-h,u=H(s,function(t){return t.interactive!==!1||"group"===t.marktype?a.pick(t,n,i,l,h):null}),t.restore(),u?u:(u=e.interactive!==!1&&(s.fill||s.stroke)&&l>=0&&l<=s.width&&h>=0&&h<=s.height,u?s:null)})}function nt(t,e){var n=t.image;return n&&n.url===t.url||(n={loaded:!1,width:0,height:0},e.loadImage(t.url).then(function(e){t.image=e,t.image.url=t.url})),n}function it(t,e){return"center"===t?e/2:"right"===t?e:0}function rt(t,e){return"middle"===t?e/2:"bottom"===t?e:0}function ot(t,e,n){var i=nt(e,n),r=e.x||0,o=e.y||0,a=e.width||i.width||0,s=e.height||i.height||0;r-=it(e.align,a),o-=rt(e.baseline,s),t("href",i.src||"","http://www.w3.org/1999/xlink","xlink:href"),t("transform",Ze(r,o)),t("width",a),t("height",s)}function at(t,e){var n=e.image,i=e.x||0,r=e.y||0,o=e.width||n&&n.width||0,a=e.height||n&&n.height||0;return i-=it(e.align,o),r-=rt(e.baseline,a),t.set(i,r,i+o,r+a)}function st(t,e,n){var i=this;B(e,function(e){if(!n||n.intersects(e.bounds)){var r,o=nt(e,i),a=e.x||0,s=e.y||0,u=e.width||o.width||0,l=e.height||o.height||0;a-=it(e.align,u),s-=rt(e.baseline,l),o.loaded&&(t.globalAlpha=null!=(r=e.opacity)?r:1,t.drawImage(o,a,s,u,l))}})}function ut(t,e){t("transform",Fe(e)),t("d",e.path)}function lt(t,e){var n=e.path;if(null==n)return!0;var i=e.pathCache;i&&i.path===n||((e.pathCache=i=be(n)).path=n),Pe(t,i,e.x,e.y)}function ht(t,e){return lt(E(t),e)?t.set(0,0,0,0):Ve(t,e)}function ct(t,e){t("d",D(null,e))}function ft(t,e){var n,i;return Ve(t.set(n=e.x||0,i=e.y||0,n+e.width||0,i+e.height||0),e)}function dt(t,e){t.beginPath(),D(t,e)}function vt(t,e){t("transform",Fe(e)),t("x2",null!=e.x2?e.x2-(e.x||0):0),t("y2",null!=e.y2?e.y2-(e.y||0):0)}function gt(t,e){var n,i;return Ve(t.set(n=e.x||0,i=e.y||0,null!=e.x2?e.x2:n,null!=e.y2?e.y2:i),e)}function pt(t,e,n){var i,r,o,a;return!(!e.stroke||!$e(t,e,n))&&(i=e.x||0,r=e.y||0,o=null!=e.x2?e.x2:i,a=null!=e.y2?e.y2:r,t.beginPath(),t.moveTo(i,r),t.lineTo(o,a),!0)}function yt(t,e,n){B(e,function(e){if(!n||n.intersects(e.bounds)){var i=null==e.opacity?1:e.opacity;i&&pt(t,e,i)&&t.stroke()}})}function _t(t,e,n,i){return!!t.isPointInStroke&&(pt(t,e,1)&&t.isPointInStroke(n,i))}function mt(t){return~~(.8*kt(t).length*bt(t))}function xt(t){return He.font=wt(t),He.measureText(kt(t.text)).width}function bt(t){return null!=t.fontSize?t.fontSize:11}function kt(t){return null!=t?String(t):""}function wt(t,e){var n=t.font;return e&&n&&(n=String(n).replace(/\"/g,"'")),""+(t.fontStyle?t.fontStyle+" ":"")+(t.fontVariant?t.fontVariant+" ":"")+(t.fontWeight?t.fontWeight+" ":"")+bt(t)+"px "+(n||"sans-serif")}function Tt(t){var e=t.baseline,n=bt(t);return Math.round("top"===e?.93*n:"middle"===e?.3*n:"bottom"===e?-.21*n:0)}function Mt(t,e){var n,i=e.dx||0,r=(e.dy||0)+Tt(e),o=e.x||0,a=e.y||0,s=e.angle||0,u=e.radius||0;u&&(n=(e.theta||0)-Math.PI/2,o+=u*Math.cos(n),a+=u*Math.sin(n)),t("text-anchor",dn[e.align]||"start"),s?(n=Ze(o,a)+" rotate("+s+")",(i||r)&&(n+=" "+Ze(i,r))):n=Ze(o+i,a+r),t("transform",n)}function Pt(t,e,n){var i,r,o=fn.height(e),a=e.align,s=e.radius||0,u=e.x||0,l=e.y||0,h=e.dx||0,c=(e.dy||0)+Tt(e)-Math.round(.8*o);return s&&(r=(e.theta||0)-Math.PI/2,u+=s*Math.cos(r),l+=s*Math.sin(r)),i=fn.width(e),"center"===a?h-=i/2:"right"===a&&(h-=i),t.set(h+=u,c+=l,h+i,c+o),e.angle&&!n&&t.rotate(e.angle*Math.PI/180,u,l),t.expand(n?0:1)}function At(t,e,n){B(e,function(e){var i,r,o,a,s,u;n&&!n.intersects(e.bounds)||(u=kt(e.text))&&(i=null==e.opacity?1:e.opacity,0!==i&&(t.font=wt(e),t.textAlign=e.align||"left",r=e.x||0,o=e.y||0,(a=e.radius)&&(s=(e.theta||0)-Math.PI/2,r+=a*Math.cos(s),o+=a*Math.sin(s)),e.angle&&(t.save(),t.translate(r,o),t.rotate(e.angle*Math.PI/180),r=o=0),r+=e.dx||0,o+=(e.dy||0)+Tt(e),e.fill&&Ue(t,e,i)&&t.fillText(u,r,o),e.stroke&&$e(t,e,i)&&t.strokeText(u,r,o),e.angle&&t.restore()))})}function zt(t,e,n,i,r,o){if(e.fontSize<=0)return!1;if(!e.angle)return!0;var a=Pt(vn,e,!0),s=-e.angle*Math.PI/180,u=Math.cos(s),l=Math.sin(s),h=e.x,c=e.y,f=u*r-l*o+(h-h*u+c*l),d=l*r+u*o+(c-h*l-c*u);return a.contains(f,d)}function Ct(t,e){return JSON.stringify(t,xn,e)}function St(t){var e="string"==typeof t?JSON.parse(t):t;return It(e)}function It(t){var e,n,i,r=t.marktype,o=t.items;if(o)for(n=0,i=o.length;n<i;++n)e=r?"mark":"group",o[n][e]=t,o[n].zindex&&(o[n][e].zdirty=!0),"group"===(r||e)&&It(o[n]);return r&&mn(t),t}function qt(t){arguments.length?this.root=St(t):(this.root=Nt({marktype:"group",name:"root",role:"frame"}),this.root.items=[new a(this.root)])}function Ot(t){throw Error(t)}function Nt(t,e){return{bounds:new r,bounds_prev:new r,clip:!!t.clip,group:e,interactive:t.interactive!==!1,items:[],marktype:t.marktype,name:t.name||void 0,role:t.role||void 0,zindex:t.zindex||0}}function Rt(){this._active=null,this._handlers={}}function Dt(t){this._el=null,this._bgcolor=null,this._loader=new s(t)}function Lt(t,e,n){return n?t.createElementNS(n,e):t.createElement(e)}function Et(t,e){e=e.toLowerCase();for(var n=t.childNodes,i=0,r=n.length;i<r;++i)if(n[i].tagName.toLowerCase()===e)return n[i]}function Wt(t,e,n,i){var r,o=t.childNodes[e];return o&&o.tagName.toLowerCase()===n.toLowerCase()||(r=o||null,o=Lt(t.ownerDocument,n,i),t.insertBefore(o,r)),o}function Gt(t,e){for(var n=t.childNodes,i=n.length;i>e;)t.removeChild(n[--i]);return t}function Vt(t){return"mark-"+t.marktype+(t.role?" role-"+t.role:"")+(t.name?" "+t.name:"")}function jt(){Rt.call(this),this._down=null,this._touch=null,this._first=!0}function Bt(t,e,n){return function(i){var r=this._active,o=this.pickEvent(i);o===r?this.fire(t,i):(r&&r.exit||this.fire(n,i),this._active=o,this.fire(e,i),this.fire(t,i))}}function Ht(t){return function(e){this.fire(t,e),this._active=null}}function Jt(t){Dt.call(this,t),this._redraw=!1}function Xt(t,e){var n,i,o,a,s,u=new r;for(n=0,i=e.length;n<i;++n)o=e[n],a=o.mark,s=a.group,o=pn[a.marktype].nested?a:o,u.union(Ut(o.bounds,s)),o.bounds_prev&&u.union(Ut(o.bounds_prev,s));return u.round(),t.beginPath(),t.rect(u.x1,u.y1,u.width(),u.height()),t.clip(),u}function Ut(t,e){if(null==e)return t;for(var n=Sn.clear().union(t);null!=e;e=e.mark.group)n.translate(e.x||0,e.y||0);return n}function Qt(){Rt.call(this)}function $t(t,e,n){var i,r,o="<"+t;if(e)for(i in e)r=e[i],null!=r&&(o+=" "+i+'="'+r+'"');return n&&(o+=" "+n),o+">"}function Yt(t){return"</"+t+">"}function Zt(t){Dt.call(this,t),this._dirtyID=0,this._svg=null,this._root=null,this._defs=null}function Ft(t,e,n){var i,r,o;for(t=Wt(t,n,"linearGradient",Rn),t.setAttribute("id",e.id),t.setAttribute("x1",e.x1),t.setAttribute("x2",e.x2),t.setAttribute("y1",e.y1),t.setAttribute("y2",e.y2),i=0,r=e.stops.length;i<r;++i)o=Wt(t,i,"stop",Rn),o.setAttribute("offset",e.stops[i].offset),o.setAttribute("stop-color",e.stops[i].color);Gt(t,i)}function Kt(t,e,n){var i;t=Wt(t,n,"clipPath",Rn),t.setAttribute("id",e.id),i=Wt(t,0,"rect",Rn),i.setAttribute("x",0),i.setAttribute("y",0),i.setAttribute("width",e.width),i.setAttribute("height",e.height)}function te(t,e){for(;t&&t.dirty!==e;t=t.mark.group){if(t.dirty=e,!t.mark||t.mark.dirty===e)return;t.mark.dirty=e}}function ee(t,e,n){var i=e.firstChild,r=0;B(n,function(n){i=t.draw(e,n,i),++r}),Gt(e,1+r)}function ne(t,e,n,i){var r,o=t._svg;if(!o&&(r=e.ownerDocument,o=Lt(r,i,Rn),t._svg=o,t.mark&&(o.__data__=t,o.__values__={fill:"default"},"g"===i))){var a=Lt(r,"path",Rn);a.setAttribute("class","background"),o.appendChild(a),a.__data__=t}return(r||o.previousSibling!==n)&&e.insertBefore(o,n?n.nextSibling:e.firstChild),o}function ie(t,e,n){e!==Wn[t]&&(null!=e?n?En.setAttributeNS(n,t,e):En.setAttribute(t,e):n?En.removeAttributeNS(n,t):En.removeAttribute(t),Wn[t]=e)}function re(){return"undefined"!=typeof window?window.location.href:""}function oe(t){Dt.call(this,t),this._text={head:"",root:"",foot:"",defs:"",body:""},this._defs={clip_id:1,gradient:{},clipping:{}}}function ae(t,e,n,i){Bn[i||t]=e}function se(t,e,n,i){if(null==t)return"";var r,o,a,s,u,l="";for("bgrect"===n&&e.interactive===!1&&(l+="pointer-events: none;"),"text"===n&&(l+="font: "+wt(t)+";"),r=0,o=Nn.length;r<o;++r)a=Nn[r],s=On[a],u=t[a],null==u?"fill"===s&&(l+=(l.length?" ":"")+"fill: none;"):(u.id&&(i.gradient[u.id]=u,u="url(#"+u.id+")"),l+=(l.length?" ":"")+s+": "+u+";");return l?'style="'+l+'"':null}function ue(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var le=r.prototype;le.clone=function(){return new r(this)},le.clear=function(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},le.set=function(t,e,n,i){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),i<e?(this.y2=e,this.y1=i):(this.y1=e,this.y2=i),this},le.add=function(t,e){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this},le.expand=function(t){return this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t,this},le.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},le.translate=function(t,e){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this},le.rotate=function(t,e,n){var i=Math.cos(t),r=Math.sin(t),o=e-e*i+n*r,a=n-e*r-n*i,s=this.x1,u=this.x2,l=this.y1,h=this.y2;return this.clear().add(i*s-r*l+o,r*s+i*l+a).add(i*s-r*h+o,r*s+i*h+a).add(i*u-r*l+o,r*u+i*l+a).add(i*u-r*h+o,r*u+i*h+a)},le.union=function(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this},le.encloses=function(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2},le.alignsWith=function(t){return t&&(this.x1==t.x1||this.x2==t.x2||this.y1==t.y1||this.y2==t.y2)},le.intersects=function(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)},le.contains=function(t,e){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)},le.width=function(){return this.x2-this.x1},le.height=function(){return this.y2-this.y1};var he=0,ce=function(t,e){var n,i=[];return n={id:"gradient_"+he++,x1:t?t[0]:0,y1:t?t[1]:0,x2:e?e[0]:1,y2:e?e[1]:0,stops:i,stop:function(t,e){return i.push({offset:t,color:e}),n}}},fe=function(t,e){var n=t.prototype=Object.create(e.prototype);return n.constructor=t,n};fe(a,o);var de;try{de=require("canvas")}catch(t){de=null}var ve=function(t,e){var n=null;return"undefined"!=typeof document&&document.createElement?(n=document.createElement("canvas"),n.width=t,n.height=e):de&&(n=new de(t,e)),n},ge="undefined"!=typeof Image?Image:de&&de.Image||null,pe=s.prototype;pe.pending=function(){return this._pending},pe.loadImage=function(t){var e=this;return e._pending+=1,e._loader.sanitize(t,{context:"image"}).then(function(t){if(!t||!ge)throw"Image unsupported.";var n=new ge;return n.onload=function(){e._pending-=1,n.loaded=!0},n.onerror=function(){e._pending-=1,n.loaded=!1},n.src=t,n}).catch(function(){return e._pending-=1,{loaded:!1,width:0,height:0}})},pe.ready=function(){var t=this;return new Promise(function(e){function n(i){t._pending?setTimeout(function(){n(!0)},10):e(i)}n(!1)})};var ye,_e={basis:{curve:n.curveBasis},bundle:{curve:n.curveBundle,tension:"beta",value:.85},cardinal:{curve:n.curveCardinal,tension:"tension",value:0},catmullRom:{curve:n.curveCatmullRom,tension:"alpha",value:.5},linear:{curve:n.curveLinear},monotone:{horizontal:n.curveMonotoneY,vertical:n.curveMonotoneX},natural:{curve:n.curveNatural},step:{curve:n.curveStep},stepAfter:{curve:n.curveStepAfter},stepBefore:{curve:n.curveStepBefore}},me={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},xe=[/([MLHVCSQTAZmlhvcsqtaz])/g,/###/,/(\d)([-+])/g,/\s|,|###/],be=function(t){var e,n,i,r,o,a,s,u,l,h,c,f=[];for(e=t.slice().replace(xe[0],"###$1").split(xe[1]).slice(1),u=0,h=e.length;u<h;++u){for(n=e[u],i=n.slice(1).trim().replace(xe[2],"$1###$2").split(xe[3]),a=n.charAt(0),r=[a],l=0,c=i.length;l<c;++l)(o=+i[l])===o&&r.push(o);if(s=me[a.toLowerCase()],r.length-1>s)for(l=1,c=r.length;l<c;l+=s)f.push([a].concat(r.slice(l,l+s)));else f.push(r)}return f},ke={},we={},Te=[].join,Me=["l",0,0,0,0,0,0,0],Pe=function(t,e,n,i,r){var o,a,s,u,l,h=null,d=0,v=0,g=0,p=0;null==n&&(n=0),null==i&&(i=0),null==r&&(r=1),t.beginPath&&t.beginPath();for(var y=0,_=e.length;y<_;++y){switch(o=e[y],1!==r&&(o=c(o,r)),o[0]){case"l":d+=o[1],v+=o[2],t.lineTo(d+n,v+i);break;case"L":d=o[1],v=o[2],t.lineTo(d+n,v+i);break;case"h":d+=o[1],t.lineTo(d+n,v+i);break;case"H":d=o[1],t.lineTo(d+n,v+i);break;case"v":v+=o[1],t.lineTo(d+n,v+i);break;case"V":v=o[1],t.lineTo(d+n,v+i);break;case"m":d+=o[1],v+=o[2],t.moveTo(d+n,v+i);break;case"M":d=o[1],v=o[2],t.moveTo(d+n,v+i);break;case"c":a=d+o[5],s=v+o[6],g=d+o[3],p=v+o[4],t.bezierCurveTo(d+o[1]+n,v+o[2]+i,g+n,p+i,a+n,s+i),d=a,v=s;break;case"C":d=o[5],v=o[6],g=o[3],p=o[4],t.bezierCurveTo(o[1]+n,o[2]+i,g+n,p+i,d+n,v+i);break;case"s":a=d+o[3],s=v+o[4],g=2*d-g,p=2*v-p,t.bezierCurveTo(g+n,p+i,d+o[1]+n,v+o[2]+i,a+n,s+i),g=d+o[1],p=v+o[2],d=a,v=s;break;case"S":a=o[3],s=o[4],g=2*d-g,p=2*v-p,t.bezierCurveTo(g+n,p+i,o[1]+n,o[2]+i,a+n,s+i),d=a,v=s,g=o[1],p=o[2];break;case"q":a=d+o[3],s=v+o[4],g=d+o[1],p=v+o[2],t.quadraticCurveTo(g+n,p+i,a+n,s+i),d=a,v=s;break;case"Q":a=o[3],s=o[4],t.quadraticCurveTo(o[1]+n,o[2]+i,a+n,s+i),d=a,v=s,g=o[1],p=o[2];break;case"t":a=d+o[1],s=v+o[2],null===h[0].match(/[QqTt]/)?(g=d,p=v):"t"===h[0]?(g=2*d-u,p=2*v-l):"q"===h[0]&&(g=2*d-g,p=2*v-p),u=g,l=p,t.quadraticCurveTo(g+n,p+i,a+n,s+i),d=a,v=s,g=d+o[1],p=v+o[2];break;case"T":a=o[1],s=o[2],g=2*d-g,p=2*v-p,t.quadraticCurveTo(g+n,p+i,a+n,s+i),d=a,v=s;break;case"a":f(t,d+n,v+i,[o[1],o[2],o[3],o[4],o[5],o[6]+d+n,o[7]+v+i]),d+=o[6],v+=o[7];break;case"A":f(t,d+n,v+i,[o[1],o[2],o[3],o[4],o[5],o[6]+n,o[7]+i]),d=o[6],v=o[7];break;case"z":case"Z":t.closePath()}h=o}},Ae=2*Math.PI,ze=Math.sqrt(3)/2,Ce={circle:{draw:function(t,e){var n=Math.sqrt(e)/2;t.moveTo(n,0),t.arc(0,0,n,0,Ae)}},cross:{draw:function(t,e){var n=Math.sqrt(e)/2,i=n/2.5;t.moveTo(-n,-i),t.lineTo(-n,i),t.lineTo(-i,i),t.lineTo(-i,n),t.lineTo(i,n),t.lineTo(i,i),t.lineTo(n,i),t.lineTo(n,-i),t.lineTo(i,-i),t.lineTo(i,-n),t.lineTo(-i,-n),t.lineTo(-i,-i),t.closePath()}},diamond:{draw:function(t,e){var n=Math.sqrt(e)/2;t.moveTo(-n,0),t.lineTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.closePath()}},square:{draw:function(t,e){var n=Math.sqrt(e),i=-n/2;t.rect(i,i,n,n)}},"triangle-up":{draw:function(t,e){var n=Math.sqrt(e)/2,i=ze*n;t.moveTo(0,-i),t.lineTo(-n,i),t.lineTo(n,i),t.closePath()}},"triangle-down":{draw:function(t,e){var n=Math.sqrt(e)/2,i=ze*n;t.moveTo(0,i),t.lineTo(-n,-i),t.lineTo(n,-i),t.closePath()}},"triangle-right":{draw:function(t,e){var n=Math.sqrt(e)/2,i=ze*n;t.moveTo(i,0),t.lineTo(-i,-n),t.lineTo(-i,n),t.closePath()}},"triangle-left":{draw:function(t,e){var n=Math.sqrt(e)/2,i=ze*n;t.moveTo(-i,0),t.lineTo(i,-n),t.lineTo(i,n),t.closePath()}}},Se={},Ie=function(){function t(t,u,l){var h,c=null!=u?u:+e.call(this,t),f=null!=l?l:+n.call(this,t),d=+r.call(this,t),v=+o.call(this,t),g=+a.call(this,t);if(s||(s=h=i.path()),g<=0)s.rect(c,f,d,v);else{var p=c+d,y=f+v;s.moveTo(c+g,f),s.lineTo(p-g,f),s.quadraticCurveTo(p,f,p,f+g),s.lineTo(p,y-g),s.quadraticCurveTo(p,y,p-g,y),s.lineTo(c+g,y),s.quadraticCurveTo(c,y,c,y-g),s.lineTo(c,f+g),s.quadraticCurveTo(c,f,c+g,f),s.closePath()}if(h)return s=null,h+""||null}var e=g,n=p,r=y,o=_,a=m(0),s=null;return t.x=function(n){return arguments.length?(e="function"==typeof n?n:m(+n),t):e},t.y=function(e){return arguments.length?(n="function"==typeof e?e:m(+e),t):n},t.width=function(e){return arguments.length?(r="function"==typeof e?e:m(+e),t):r},t.height=function(e){return arguments.length?(o="function"==typeof e?e:m(+e),t):o},t.cornerRadius=function(e){return arguments.length?(a="function"==typeof e?e:m(+e),t):a},t.context=function(e){return arguments.length?(s=null==e?null:e,t):s},t},qe=Math.PI,Oe=function(){function t(t,e,n){var i=n/2;if(s){var r=l-e,o=t-u,a=Math.sqrt(r*r+o*o),f=(r/=a)*h,d=(o/=a)*h,v=Math.atan2(o,r);c.moveTo(u-f,l-d),c.lineTo(t-r*i,e-o*i),c.arc(t,e,i,v-qe,v),c.lineTo(u+f,l+d),c.arc(u,l,h,v,v+qe),c.closePath()}else s=1;u=t,l=e,h=i}function e(e){var u,l,h,f=e.length,d=!1;for(null==c&&(c=h=i.path()),u=0;u<=f;++u)!(u<f&&a(l=e[u],u,e))===d&&(d=!d)&&(s=0),d&&t(+n(l,u,e),+r(l,u,e),+o(l,u,e));if(h)return c=null,h+""||null}var n,r,o,a,s,u,l,h,c=null;return e.x=function(t){return arguments.length?(n=t,e):n},e.y=function(t){return arguments.length?(r=t,e):r},e.size=function(t){return arguments.length?(o=t,e):o},e.defined=function(t){return arguments.length?(a=t,e):a},e.context=function(t){return arguments.length?(c=null==t?null:t,e):c},e},Ne=n.arc().cornerRadius(A).padAngle(z),Re=n.area().x(x).y1(b).y0(P).defined(C),De=n.area().y(b).x1(x).x0(M).defined(C),Le=n.line().x(x).y(b).defined(C),Ee=Oe().x(x).y(b).defined(C).size(w),We=Ie().x(x).y(b).width(k).height(T).cornerRadius(A),Ge=n.symbol().type(I).size(S),Ve=function(t,e){return e.stroke&&0!==e.opacity&&0!==e.stokeOpacity&&t.expand(null!=e.strokeWidth?+e.strokeWidth:1),t},je=2*Math.PI,Be=Math.PI/2;E.beginPath=W,E.closePath=W,E.moveTo=G,E.lineTo=G,E.rect=function(t,e,n,i){G(t,e),G(t+n,e+i)},E.quadraticCurveTo=function(t,e,n,i){G(t,e),G(n,i)},E.bezierCurveTo=function(t,e,n,i,r,o){G(t,e),G(n,i),G(r,o)},E.arc=function(t,e,n,i,r,o){function a(t){l=n*Math.cos(t),h=n*Math.sin(t),l<c&&(c=l),l>f&&(f=l),h<d&&(d=h),h>v&&(v=h)}if(n===je)return G(t-n,e-n),void G(t+n,e+n);var s,u,l,h,c=1/0,f=-(1/0),d=1/0,v=-(1/0);if(a(i),a(r),o)for(s=r-r%Be,u=0;u<4&&s>i;++u,s-=Be)a(s);else for(s=i-i%Be,u=0;u<4&&s<r;++u,s+=Be)a(s);G(t+c,e+d),G(t+f,e+v)};var He,Je=function(t,e,n){for(var i=n.width(),r=n.height(),o=n.x1+e.x1*i,a=n.y1+e.y1*r,s=n.x1+e.x2*i,u=n.y1+e.y2*r,l=e.stops,h=0,c=l.length,f=t.createLinearGradient(o,a,s,u);h<c;++h)f.addColorStop(l[h].offset,l[h].color);return f},Xe=function(t,e,n){return n.id?Je(t,n,e.bounds):n},Ue=function(t,e,n){return n*=null==e.fillOpacity?1:e.fillOpacity,n>0&&(t.globalAlpha=n,t.fillStyle=Xe(t,e,e.fill),!0)},Qe=[],$e=function(t,e,n){var i,r=null!=(r=e.strokeWidth)?r:1;return!(r<=0)&&(n*=null==e.strokeOpacity?1:e.strokeOpacity,n>0&&(t.globalAlpha=n,t.strokeStyle=Xe(t,e,e.stroke),t.lineWidth=r,t.lineCap=null!=(i=e.strokeCap)?i:"butt",t.setLineDash&&(t.setLineDash(e.strokeDash||Qe),t.lineDashOffset=e.strokeDashOffset||0),!0))},Ye=function(){return!0},Ze=function(t,e){return"translate("+t+","+e+")"},Fe=function(t){return Ze(t.x||0,t.y||0)},Ke=function(t,e){function n(t,n){t("transform",Fe(n)),t("d",e(null,n))}function i(t,n){return e(E(t),n),Ve(t,n).translate(n.x||0,n.y||0)}function r(t,n){var i=n.x||0,r=n.y||0;t.translate(i,r),t.beginPath(),e(t,n),t.translate(-i,-r)}return{type:t,tag:"path",nested:!1,attr:n,bound:i,draw:J(r),pick:Y(r)}},tn=Ke("arc",q),en=function(t,e){function n(t,n){var i=n.mark.items;i.length&&t("d",e(null,i))}function i(t,n){var i=n.items;return 0===i.length?t:(e(E(t),i),Ve(t,i[0]))}function r(t,n){t.beginPath(),e(t,n)}function o(t,e,n,i,r,o){var s=e.items,u=e.bounds;return!s||!s.length||u&&!u.contains(r,o)?null:(t.pixelRatio>1&&(n*=t.pixelRatio,i*=t.pixelRatio),a(t,s,n,i)?s[0]:null)}var a=$(r);return{type:t,tag:"path",nested:!0,attr:n,bound:i,draw:X(r),pick:o}},nn=en("area",O),rn={type:"group",tag:"g",nested:!1,attr:Z,bound:K,draw:tt,pick:et,background:F},on={type:"image",tag:"image",nested:!1,attr:ot,bound:at,draw:st,pick:Q()},an=en("line",R),sn={type:"path",tag:"path",nested:!1,attr:ut,bound:ht,draw:J(lt),pick:Y(lt)},un={type:"rect",tag:"path",nested:!1,attr:ct,bound:ft,draw:J(dt),pick:Y(dt)},ln={type:"rule",tag:"line",nested:!1,attr:vt,bound:gt,draw:yt,pick:Q(_t)},hn=Ke("shape",N),cn=Ke("symbol",L),fn={height:bt,measureWidth:xt,estimateWidth:mt,width:(He=ve(1,1))?(He=He.getContext("2d"),xt):mt},dn={left:"start",center:"middle",right:"end"},vn=new r,gn={type:"text",tag:"text",nested:!1,attr:Mt,bound:Pt,draw:At,pick:Q(zt)},pn={arc:tn,area:nn,group:rn,image:on,line:an,path:sn,rect:un,rule:ln,shape:hn,symbol:cn,text:gn},yn=function(t,e,n){var i=pn[t.mark.marktype],o=e||i.bound;i.nested&&(t=t.mark);var a=t.bounds,s=t.bounds_prev||(t.bounds_prev=new r);return a?(s.clear().union(a),a.clear()):t.bounds=new r,o(t.bounds,t,n),a||s.clear().union(t.bounds),t.bounds},_n={mark:null},mn=function(t,e,n){var i,o,a,s,u=pn[t.marktype],l=u.bound,h=t.items,c=h&&h.length;if(u.nested)return a=c?h[0]:(_n.mark=t,_n),s=yn(a,l,n),e=e&&e.union(s)||s;if(e=e||t.bounds&&t.bounds.clear()||new r,c)for(i=0,o=h.length;i<o;++i)e.union(yn(h[i],l,n));return t.bounds=e},xn=["marktype","name","role","interactive","clip","items","zindex","x","y","width","height","align","baseline","fill","fillOpacity","opacity","stroke","strokeOpacity","strokeWidth","strokeCap","strokeDash","strokeDashOffset","startAngle","endAngle","innerRadius","outerRadius","cornerRadius","padAngle","interpolate","tension","orient","defined","url","path","x2","y2","size","shape","text","angle","theta","radius","dx","dy","font","fontSize","fontWeight","fontStyle","fontVariant"],bn=qt.prototype;bn.toJSON=function(t){return Ct(this.root,t||0)},bn.mark=function(t,e){var n,i,r,o,a=t.marks,s=t.items,u=this.root.items[0];try{for(r=0,o=a.length;r<o&&(n=u.items[a[r]],n);++r)i=s[r]||0,u=n.items[i]||n.items[n.items.length-1];if(!n)return n=Nt(e,u),u.items[a[r]]=n,n.zindex&&(n.group.zdirty=!0),n;throw o}catch(e){Ot("Invalid scenegraph path: "+JSON.stringify(t))}};var kn=Rt.prototype;kn.initialize=function(t,e,n){return this._el=t,this._obj=n||null,this.origin(e)},kn.element=function(){return this._el},kn.origin=function(t){return this._origin=t||[0,0],this},kn.scene=function(t){return arguments.length?(this._scene=t,this):this._scene},kn.on=function(){},kn.off=function(){},kn.handlers=function(){var t,e=this._handlers,n=[];for(t in e)n.push.apply(n,e[t]);return n},kn.eventName=function(t){var e=t.indexOf(".");return e<0?t:t.slice(0,e)};var wn=Dt.prototype;wn.initialize=function(t,e,n,i){return this._el=t,this.resize(e,n,i)},wn.element=function(){return this._el},wn.scene=function(){return this._el&&this._el.firstChild},wn.background=function(t){return 0===arguments.length?this._bgcolor:(this._bgcolor=t,this)},wn.resize=function(t,e,n){return this._width=t,this._height=e,this._origin=n||[0,0],this},wn.render=function(t,e){var n=this;return n._call=function(){n._render(t,e)},n._call(),n._call=null,n},wn._render=function(){},wn.renderAsync=function(t,e){var n=this.render(t,e);return this._ready?this._ready.then(function(){return n}):Promise.resolve(n)},wn.loadImage=function(t){var e=this,n=e._loader.loadImage(t);if(!e._ready){var i=e._call;e._ready=e._loader.ready().then(function(t){t&&i(),e._ready=null})}return n};var Tn=function(t,e){var n=e.getBoundingClientRect();return[t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0)]},Mn=fe(jt,Rt);Mn.initialize=function(t,e,n){var i=this._canvas=t&&Et(t,"canvas");if(i){var r=this;this.events.forEach(function(t){i.addEventListener(t,function(e){Mn[t]?Mn[t].call(r,e):r.fire(t,e)})})}return Rt.prototype.initialize.call(this,t,e,n)},Mn.canvas=function(){return this._canvas},Mn.context=function(){return this._canvas.getContext("2d")},Mn.events=["keydown","keypress","keyup","dragenter","dragleave","dragover","mousedown","mouseup","mousemove","mouseout","mouseover","click","dblclick","wheel","mousewheel","touchstart","touchmove","touchend"],Mn.DOMMouseScroll=function(t){this.fire("mousewheel",t)},Mn.mousemove=Bt("mousemove","mouseover","mouseout"),Mn.dragover=Bt("dragover","dragenter","dragleave"),Mn.mouseout=Ht("mouseout"),Mn.dragleave=Ht("dragleave"),Mn.mousedown=function(t){this._down=this._active,this.fire("mousedown",t)},Mn.click=function(t){this._down===this._active&&(this.fire("click",t),this._down=null)},Mn.touchstart=function(t){this._touch=this.pickEvent(t.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire("touchstart",t,!0)},Mn.touchmove=function(t){this.fire("touchmove",t,!0)},Mn.touchend=function(t){this.fire("touchend",t,!0),this._touch=null},Mn.fire=function(t,e,n){var i,r,o=n?this._touch:this._active,a=this._handlers[t];if(a)for(e.vegaType=t,i=0,r=a.length;i<r;++i)a[i].handler.call(this._obj,e,o)},Mn.on=function(t,e){var n=this.eventName(t),i=this._handlers;return(i[n]||(i[n]=[])).push({type:t,handler:e}),this},Mn.off=function(t,e){var n,i=this.eventName(t),r=this._handlers[i];if(r){for(n=r.length;--n>=0;)r[n].type===t&&(e&&r[n].handler!==e||r.splice(n,1));return this}},Mn.pickEvent=function(t){var e=Tn(t,this._canvas),n=this._origin;return this.pick(this._scene,e[0],e[1],e[0]-n[0],e[1]-n[1])},Mn.pick=function(t,e,n,i,r){var o=this.context(),a=pn[t.marktype];return a.pick.call(this,o,t,e,n,i,r)};var Pn="undefined"!=typeof window?window.devicePixelRatio||1:1,An=function(t,e,n,i){var r="undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&null!=t.parentNode,o=t.getContext("2d"),a=r?Pn:1;return t.width=e*a,t.height=n*a,1!==a&&(t.style.width=e+"px",t.style.height=n+"px"),o.pixelRatio=a,o.setTransform(a,0,0,a,a*i[0],a*i[1]),t},zn=fe(Jt,Dt),Cn=Dt.prototype,Sn=new r;zn.initialize=function(t,e,n,i){return this._canvas=ve(1,1),t&&(Gt(t,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),Cn.initialize.call(this,t,e,n,i)},zn.resize=function(t,e,n){return Cn.resize.call(this,t,e,n),An(this._canvas,this._width,this._height,this._origin),this._redraw=!0,this},zn.canvas=function(){return this._canvas},zn.context=function(){return this._canvas?this._canvas.getContext("2d"):null},zn._render=function(t,e){var n,i=this.context(),r=this._origin,o=this._width,a=this._height;return i.save(),n=!e||this._redraw?(this._redraw=!1,null):Xt(i,e),this.clear(-r[0],-r[1],o,a),this.draw(i,t,n),i.restore(),this},zn.draw=function(t,e,n){var i=pn[e.marktype];i.draw.call(this,t,e,n)},zn.clear=function(t,e,n,i){var r=this.context();r.clearRect(t,e,n,i),null!=this._bgcolor&&(r.fillStyle=this._bgcolor,r.fillRect(t,e,n,i))};var In=fe(Qt,Rt);In.initialize=function(t,e,n){return this._svg=t&&Et(t,"svg"),Rt.prototype.initialize.call(this,t,e,n)},In.svg=function(){return this._svg},In.listener=function(t){var e=this;return function(n){var i=n.target,r=i.__data__;n.vegaType=n.type,r=Array.isArray(r)?r[0]:r,t.call(e._obj,n,r)}},In.on=function(t,e){
var n=this.eventName(t),i=this._handlers,r={type:t,handler:e,listener:this.listener(e)};return(i[n]||(i[n]=[])).push(r),this._svg&&this._svg.addEventListener(n,r.listener),this},In.off=function(t,e){var n,i=this.eventName(t),r=this._svg,o=this._handlers[i];if(o){for(n=o.length;--n>=0;)(o[n].type===t&&!e||o[n].handler===e)&&(this._svg&&r.removeEventListener(i,o[n].listener),o.splice(n,1));return this}};var qn={version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},On={fill:"fill",fillOpacity:"fill-opacity",stroke:"stroke",strokeWidth:"stroke-width",strokeOpacity:"stroke-opacity",strokeCap:"stroke-linecap",strokeDash:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",opacity:"opacity"},Nn=Object.keys(On),Rn=qn.xmlns,Dn=fe(Zt,Dt),Ln=Dt.prototype;Dn.initialize=function(t,e,n,i){return t&&(this._svg=Wt(t,0,"svg",Rn),this._svg.setAttribute("class","marks"),Gt(t,1),this._root=Wt(this._svg,0,"g",Rn),Gt(this._svg,1)),this._defs={clip_id:1,gradient:{},clipping:{}},this.background(this._bgcolor),Ln.initialize.call(this,t,e,n,i)},Dn.background=function(t){return arguments.length&&this._svg&&this._svg.style.setProperty("background-color",t),Ln.background.apply(this,arguments)},Dn.resize=function(t,e,n){return Ln.resize.call(this,t,e,n),this._svg&&(this._svg.setAttribute("width",this._width),this._svg.setAttribute("height",this._height),this._root.setAttribute("transform","translate("+this._origin+")")),this},Dn.svg=function(){if(!this._svg)return null;var t={class:"marks",width:this._width,height:this._height};for(var e in qn)t[e]=qn[e];return $t("svg",t)+this._svg.innerHTML+Yt("svg")},Dn._render=function(t,e){return this._dirtyCheck(e)&&(this._dirtyAll&&this._resetDefs(),this.draw(this._root,t),Gt(this._root,1)),this.updateDefs(),this},Dn.updateDefs=function(){var t,e=this._svg,n=this._defs,i=n.el,r=0;for(t in n.gradient)i||(n.el=i=Wt(e,0,"defs",Rn)),Ft(i,n.gradient[t],r++);for(t in n.clipping)i||(n.el=i=Wt(e,0,"defs",Rn)),Kt(i,n.clipping[t],r++);i&&(0===r?(e.removeChild(i),n.el=null):Gt(i,r))},Dn._resetDefs=function(){var t=this._defs;t.clip_id=1,t.gradient={},t.clipping={}},Dn.isDirty=function(t){return this._dirtyAll||!t._svg||t.dirty===this._dirtyID},Dn._dirtyCheck=function(t){if(this._dirtyAll=!0,!t)return!0;var e,n,i,r,o,a,s,u=++this._dirtyID;for(o=0,a=t.length;o<a;++o)e=t[o],n=e.mark,n.marktype!==i&&(i=n.marktype,r=pn[i]),n.zdirty&&n.dirty!==u&&(this._dirtyAll=!1,n.dirty=u,te(n.group,u)),e.exit?(r.nested&&n.items.length?(s=n.items[0],s._svg&&this._update(r,s._svg,s)):e._svg&&e._svg.remove(),e._svg=null):(e=r.nested?n.items[0]:e,e._update!==u&&(e._svg&&e._svg.ownerSVGElement?this._update(r,e._svg,e):(this._dirtyAll=!1,te(e,u)),e._update=u));return!this._dirtyAll},Dn.draw=function(t,e,n){function i(t){var e=o.isDirty(t),n=ne(t,r,l,a.tag);e&&(o._update(a,n,t),u&&ee(o,n,t)),l=n,++h}if(!this.isDirty(e))return e._svg;var r,o=this,a=pn[e.marktype],s=e.interactive===!1?"none":null,u="g"===a.tag,l=null,h=0;return r=ne(e,t,n,"g"),r.setAttribute("class",Vt(e)),!u&&s&&r.style.setProperty("pointer-events",s),a.nested?e.items.length&&i(e.items[0]):B(e,i),Gt(r,h),r};var En=null,Wn=null,Gn={group:function(t,e,n){En=e.childNodes[0],Wn=e.__values__,t.background(ie,n,this);var i=n.mark.interactive===!1?"none":null;i!==Wn.events&&(En.style.setProperty("pointer-events",i),Wn.events=i)},text:function(t,e,n){var i=kt(n.text);i!==Wn.text&&(e.textContent=i,Wn.text=i),i=wt(n),i!==Wn.font&&(e.style.setProperty("font",i),Wn.font=i)}};Dn._update=function(t,e,n){En=e,Wn=e.__values__,t.attr(ie,n,this);var i=Gn[t.type];i&&i(t,e,n),this.style(En,n)},Dn.style=function(t,e){if(null!=e){var n,i,r,o,a;for(n=0,i=Nn.length;n<i;++n)r=Nn[n],a=e[r],a!==Wn[r]&&(o=On[r],null==a?"fill"===o?t.style.setProperty(o,"none"):t.style.removeProperty(o):(a.id&&(this._defs.gradient[a.id]=a,a="url("+re()+"#"+a.id+")"),t.style.setProperty(o,a+"")),Wn[r]=a)}};var Vn=fe(oe,Dt),jn=Dt.prototype;Vn.resize=function(t,e,n){jn.resize.call(this,t,e,n);var i=this._origin,r=this._text,o={class:"marks",width:this._width,height:this._height};for(var a in qn)o[a]=qn[a];return r.head=$t("svg",o),r.root=$t("g",{transform:"translate("+i+")"}),r.foot=Yt("g")+Yt("svg"),this},Vn.svg=function(){var t=this._text;return t.head+t.defs+t.root+t.body+t.foot},Vn._render=function(t){return this._text.body=this.mark(t),this._text.defs=this.buildDefs(),this},Vn.reset=function(){return this._defs.clip_id=0,this},Vn.buildDefs=function(){var t,e,n,i,r=this._defs,o="";for(e in r.gradient){for(n=r.gradient[e],i=n.stops,o+=$t("linearGradient",{id:e,x1:n.x1,x2:n.x2,y1:n.y1,y2:n.y2}),t=0;t<i.length;++t)o+=$t("stop",{offset:i[t].offset,"stop-color":i[t].color})+Yt("stop");o+=Yt("linearGradient")}for(e in r.clipping)n=r.clipping[e],o+=$t("clipPath",{id:e}),o+=$t("rect",{x:0,y:0,width:n.width,height:n.height})+Yt("rect"),o+=Yt("clipPath");return o.length>0?$t("defs")+o+Yt("defs"):""};var Bn;Vn.attributes=function(t,e){return Bn={},t(ae,e,this),Bn},Vn.mark=function(t){function e(e){n="g"!==o?se(e,t,o,a):null,s+=$t(o,i.attributes(r.attr,e),n),"text"===o?s+=ue(kt(e.text)):"g"===o&&(s+=$t("path",i.attributes(r.background,e),se(e,t,"bgrect",a))+Yt("path"),s+=i.markGroup(e)),s+=Yt(o)}var n,i=this,r=pn[t.marktype],o=r.tag,a=this._defs,s="";return"g"!==o&&t.interactive===!1&&(n='style="pointer-events: none;"'),s+=$t("g",{class:Vt(t)},n),r.nested?t.items&&t.items.length&&e(t.items[0]):B(t,e),s+Yt("g")},Vn.markGroup=function(t){var e=this,n="";return B(t,function(t){n+=e.mark(t)}),n};var Hn=function(t,e,n,i){var r,o,a,s=ce(e,n),u=t.domain(),l=u[0],h=u[u.length-1];for("linear"!==t.type&&t.ticks&&(u=t.ticks(+i||15),l!==u[0]&&u.unshift(l),h!==u[u.length-1]&&u.push(h)),a=t.range?t.copy().domain([l,h]).range([0,1]):function(t){return(t-l)/(h-l)},r=0,o=u.length;r<o;++r)s.stop(a(u[r]),t(u[r]));return s};t.Bounds=r,t.Gradient=ce,t.GroupItem=a,t.ImageLoader=s,t.Item=o,t.Scenegraph=qt,t.Handler=Rt,t.Renderer=Dt,t.CanvasHandler=jt,t.CanvasRenderer=Jt,t.SVGHandler=Qt,t.SVGRenderer=Zt,t.SVGStringRenderer=oe,t.boundContext=E,t.boundStroke=Ve,t.boundItem=yn,t.boundMark=mn,t.Marks=pn,t.pathParse=be,t.pathRender=Pe,t.scaleGradient=Hn,t.point=Tn,t.canvas=ve,t.openTag=$t,t.closeTag=Yt,t.font=wt,t.textMetrics=fn,t.toJSON=Ct,t.fromJSON=St,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-loader"),require("d3-shape"),require("d3-path")):"function"==typeof define&&define.amd?define(["exports","vega-loader","d3-shape","d3-path"],e):e(t.vega=t.vega||{},t.vega,t.d3,t.d3)}(this,function(t,e,n,i){"use strict";function r(t){this.clear(),t&&this.union(t)}function o(t){this.mark=t,this.bounds=this.bounds||new r,this.bounds_prev=this.bounds_prev||new r}function a(t){o.call(this,t),this.items=this.items||[]}function s(t){this._pending=0,this._loader=t||e.loader()}function u(t){t._pending+=1}function l(t){t._pending-=1}function h(t,e,n){var i=be.hasOwnProperty(t)&&be[t],r=null;return i&&(r=i.curve||i[e||"vertical"],i.tension&&null!=n&&(r=r[i.tension](n))),r}function c(t,e,n,i,r,o,a,s,u){var l=Ae.call(arguments);if(Me[l])return Me[l];var h=a*(Math.PI/180),c=Math.sin(h),f=Math.cos(h);n=Math.abs(n),i=Math.abs(i);var d=f*(s-t)*.5+c*(u-e)*.5,v=f*(u-e)*.5-c*(s-t)*.5,g=d*d/(n*n)+v*v/(i*i);g>1&&(g=Math.sqrt(g),n*=g,i*=g);var p=f/n,y=c/n,_=-c/i,m=f/i,x=p*s+y*u,b=_*s+m*u,k=p*t+y*e,w=_*t+m*e,T=(k-x)*(k-x)+(w-b)*(w-b),M=1/T-.25;M<0&&(M=0);var z=Math.sqrt(M);o==r&&(z=-z);var A=.5*(x+k)-z*(w-b),P=.5*(b+w)+z*(k-x),C=Math.atan2(b-P,x-A),S=Math.atan2(w-P,k-A),I=S-C;I<0&&1===o?I+=2*Math.PI:I>0&&0===o&&(I-=2*Math.PI);for(var q=Math.ceil(Math.abs(I/(.5*Math.PI+.001))),R=[],L=0;L<q;++L){var O=C+L*I/q,E=C+(L+1)*I/q;R[L]=[A,P,O,E,n,i,c,f]}return Me[l]=R}function f(t){var e=Ae.call(t);if(ze[e])return ze[e];var n=t[0],i=t[1],r=t[2],o=t[3],a=t[4],s=t[5],u=t[6],l=t[7],h=l*a,c=-u*s,f=u*a,d=l*s,v=Math.cos(r),g=Math.sin(r),p=Math.cos(o),y=Math.sin(o),_=.5*(o-r),m=Math.sin(.5*_),x=8/3*m*m/Math.sin(_),b=n+v-x*g,k=i+g+x*v,w=n+p,T=i+y,M=w+x*y,z=T-x*p;return ze[e]=[h*b+c*k,f*b+d*k,h*M+c*z,f*M+d*z,h*w+c*T,f*w+d*T]}function d(t,e){var n=Pe[0]=t[0];if("a"===n||"A"===n)Pe[1]=e*t[1],Pe[2]=e*t[2],Pe[6]=e*t[6],Pe[7]=e*t[7];else for(var i=1,r=t.length;i<r;++i)Pe[i]=e*t[i];return Pe}function v(t,e,n,i){for(var r=c(i[5],i[6],i[0],i[1],i[3],i[4],i[2],e,n),o=0;o<r.length;++o){var a=f(r[o]);t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5])}}function g(t){return qe.hasOwnProperty(t)?qe[t]:p(t)}function p(t){if(!Re.hasOwnProperty(t)){var e=Te(t);Re[t]={draw:function(t,n){Ce(t,e,0,0,Math.sqrt(n))}}}return Re[t]}function y(t){return t.x}function _(t){return t.y}function m(t){return t.width}function x(t){return t.height}function b(t){return function(){return t}}function k(t){return t.x||0}function w(t){return t.y||0}function T(t){return t.width||0}function M(t){return t.width||t.height||1}function z(t){return t.height||0}function A(t){return(t.x||0)+(t.width||0)}function P(t){return(t.y||0)+(t.height||0)}function C(t){return t.cornerRadius||0}function S(t){return t.padAngle||0}function I(t){return!(t.defined===!1)}function q(t){return null==t.size?64:t.size}function R(t){return g(t.shape||"circle")}function L(t,e){return Ne.context(t)(e)}function O(t,e){var n=e[0],i=n.interpolate||"linear";return("trail"===i?Ge:("horizontal"===n.orient?He:De).curve(h(i,n.orient,n.tension))).context(t)(e)}function E(t,e){return(e.mark.shape||e.shape).context(t)(e)}function N(t,e){var n=e[0],i=n.interpolate||"linear";return We.curve(h(i,n.orient,n.tension)).context(t)(e)}function D(t,e,n,i){return Ve.context(t)(e,n,i)}function H(t,e){return Be.context(t)(e)}function W(t){return xe=t,W}function G(){}function V(t,e){xe.add(t,e)}function B(t,e){return t.zindex-e.zindex||t.index-e.index}function j(t){if(!t.zdirty)return t.zitems;var e,n,i,r=t.items,o=[];for(n=0,i=r.length;n<i;++n)e=r[n],e.index=n,e.zindex&&o.push(e);return t.zdirty=!1,t.zitems=o.sort(B)}function U(t,e){var n,i,r=t.items;if(r&&r.length){var o=j(t);if(o&&o.length){for(n=0,i=r.length;n<i;++n)r[n].zindex||e(r[n]);r=o}for(n=0,i=r.length;n<i;++n)e(r[n])}}function J(t,e){var n,i,r=t.items;if(!r||!r.length)return null;var o=j(t);for(o&&o.length&&(r=o),i=r.length;--i>=0;)if(n=e(r[i]))return n;if(r===o)for(r=t.items,i=r.length;--i>=0;)if(!r[i].zindex&&(n=e(r[i])))return n;return null}function X(t){return function(e,n,i){U(n,function(n){i&&!i.intersects(n.bounds)||$(t,e,n,n)})}}function Q(t){return function(e,n,i){!n.items.length||i&&!i.intersects(n.bounds)||$(t,e,n.items[0],n.items)}}function $(t,e,n,i){var r=null==n.opacity?1:n.opacity;0!==r&&(t(e,i)||(n.fill&&Ye(e,n,r)&&e.fill(),n.stroke&&Fe(e,n,r)&&e.stroke()))}function Y(t){return t||(t=Ke),function(e,n,i,r,o,a){return e.pixelRatio>1&&(i*=e.pixelRatio,r*=e.pixelRatio),J(n,function(n){var s=n.bounds;if((!s||s.contains(o,a))&&s)return t(e,n,i,r,o,a)?n:void 0})}}function Z(t,e){return function(n,i,r,o){var a,s,u=Array.isArray(i)?i[0]:i,l=null==e?u.fill:e,h=u.stroke&&n.isPointInStroke;return h&&(a=u.strokeWidth,s=u.strokeCap,n.lineWidth=null!=a?a:1,n.lineCap=null!=s?s:"butt"),!t(n,i)&&(l&&n.isPointInPath(r,o)||h&&n.isPointInStroke(r,o))}}function F(t){return Y(Z(t))}function K(t,e,n){var i,r,o=null;t("transform",en(e)),e.clip&&(i=n._defs,o=e.clip_id||(e.clip_id="clip"+i.clip_id++),r=i.clipping[o]||(i.clipping[o]={id:o}),r.width=e.width||0,r.height=e.height||0),t("clip-path",o?"url(#"+o+")":null)}function tt(t,e){var n=e.stroke?.5:0;t("class","background"),t("d",D(null,e,n,n))}function et(t,e){if(!e.clip&&e.items)for(var n=e.items,i=0,r=n.length;i<r;++i)t.union(n[i].bounds);return(e.clip||e.width||e.height)&&je(t.add(0,0).add(e.width||0,e.height||0),e),t.translate(e.x||0,e.y||0)}function nt(t,e,n){var i=this;U(e,function(e){var r,o,a=e.x||0,s=e.y||0,u=e.width||0,l=e.height||0;t.save(),t.translate(a,s),(e.stroke||e.fill)&&(o=null==e.opacity?1:e.opacity,o>0&&(t.beginPath(),r=e.stroke?.5:0,D(t,e,r,r),e.fill&&Ye(t,e,o)&&t.fill(),e.stroke&&Fe(t,e,o)&&t.stroke())),e.clip&&(t.beginPath(),t.rect(0,0,u,l),t.clip()),n&&n.translate(-a,-s),U(e,function(e){i.draw(t,e,n)}),n&&n.translate(a,s),t.restore()})}function it(t,e,n,i,r,o){if(e.bounds&&!e.bounds.contains(r,o)||!e.items)return null;var a=this;return J(e,function(s){var u,l,h,c;if(c=s.bounds,!c||c.contains(r,o))return l=s.x||0,h=s.y||0,t.save(),t.translate(l,h),l=r-l,h=o-h,u=J(s,function(t){return t.interactive!==!1||"group"===t.marktype?a.pick(t,n,i,l,h):null}),t.restore(),u?u:(u=e.interactive!==!1&&(s.fill||s.stroke)&&l>=0&&l<=s.width&&h>=0&&h<=s.height,u?s:null)})}function rt(t,e){var n=t.image;return n&&n.url===t.url||(n={loaded:!1,width:0,height:0},e.loadImage(t.url).then(function(e){t.image=e,t.image.url=t.url})),n}function ot(t,e){return"center"===t?e/2:"right"===t?e:0}function at(t,e){return"middle"===t?e/2:"bottom"===t?e:0}function st(t,e,n){var i=rt(e,n),r=e.x||0,o=e.y||0,a=e.width||i.width||0,s=e.height||i.height||0;r-=ot(e.align,a),o-=at(e.baseline,s),t("href",i.src||"","http://www.w3.org/1999/xlink","xlink:href"),t("transform",tn(r,o)),t("width",a),t("height",s)}function ut(t,e){var n=e.image,i=e.x||0,r=e.y||0,o=e.width||n&&n.width||0,a=e.height||n&&n.height||0;return i-=ot(e.align,o),r-=at(e.baseline,a),t.set(i,r,i+o,r+a)}function lt(t,e,n){var i=this;U(e,function(e){if(!n||n.intersects(e.bounds)){var r,o=rt(e,i),a=e.x||0,s=e.y||0,u=e.width||o.width||0,l=e.height||o.height||0;a-=ot(e.align,u),s-=at(e.baseline,l),o.loaded&&(t.globalAlpha=null!=(r=e.opacity)?r:1,t.drawImage(o,a,s,u,l))}})}function ht(t,e){t("transform",en(e)),t("d",e.path)}function ct(t,e){var n=e.path;if(null==n)return!0;var i=e.pathCache;i&&i.path===n||((e.pathCache=i=Te(n)).path=n),Ce(t,i,e.x,e.y)}function ft(t,e){return ct(W(t),e)?t.set(0,0,0,0):je(t,e)}function dt(t,e){t("d",D(null,e))}function vt(t,e){var n,i;return je(t.set(n=e.x||0,i=e.y||0,n+e.width||0,i+e.height||0),e)}function gt(t,e){t.beginPath(),D(t,e)}function pt(t,e){t("transform",en(e)),t("x2",null!=e.x2?e.x2-(e.x||0):0),t("y2",null!=e.y2?e.y2-(e.y||0):0)}function yt(t,e){var n,i;return je(t.set(n=e.x||0,i=e.y||0,null!=e.x2?e.x2:n,null!=e.y2?e.y2:i),e)}function _t(t,e,n){var i,r,o,a;return!(!e.stroke||!Fe(t,e,n))&&(i=e.x||0,r=e.y||0,o=null!=e.x2?e.x2:i,a=null!=e.y2?e.y2:r,t.beginPath(),t.moveTo(i,r),t.lineTo(o,a),!0)}function mt(t,e,n){U(e,function(e){if(!n||n.intersects(e.bounds)){var i=null==e.opacity?1:e.opacity;i&&_t(t,e,i)&&t.stroke()}})}function xt(t,e,n,i){return!!t.isPointInStroke&&(_t(t,e,1)&&t.isPointInStroke(n,i))}function bt(t){return~~(.8*Tt(t).length*wt(t))}function kt(t){return Xe.font=Mt(t),Xe.measureText(Tt(t.text)).width}function wt(t){return null!=t.fontSize?t.fontSize:11}function Tt(t){return null!=t?String(t):""}function Mt(t,e){var n=t.font;return e&&n&&(n=String(n).replace(/\"/g,"'")),""+(t.fontStyle?t.fontStyle+" ":"")+(t.fontVariant?t.fontVariant+" ":"")+(t.fontWeight?t.fontWeight+" ":"")+wt(t)+"px "+(n||"sans-serif")}function zt(t){var e=t.baseline,n=wt(t);return Math.round("top"===e?.93*n:"middle"===e?.3*n:"bottom"===e?-.21*n:0)}function At(t,e){var n,i=e.dx||0,r=(e.dy||0)+zt(e),o=e.x||0,a=e.y||0,s=e.angle||0,u=e.radius||0;u&&(n=(e.theta||0)-Math.PI/2,o+=u*Math.cos(n),a+=u*Math.sin(n)),t("text-anchor",pn[e.align]||"start"),s?(n=tn(o,a)+" rotate("+s+")",(i||r)&&(n+=" "+tn(i,r))):n=tn(o+i,a+r),t("transform",n)}function Pt(t,e,n){var i,r,o=gn.height(e),a=e.align,s=e.radius||0,u=e.x||0,l=e.y||0,h=e.dx||0,c=(e.dy||0)+zt(e)-Math.round(.8*o);return s&&(r=(e.theta||0)-Math.PI/2,u+=s*Math.cos(r),l+=s*Math.sin(r)),i=gn.width(e),"center"===a?h-=i/2:"right"===a&&(h-=i),t.set(h+=u,c+=l,h+i,c+o),e.angle&&!n&&t.rotate(e.angle*Math.PI/180,u,l),t.expand(n?0:1)}function Ct(t,e,n){U(e,function(e){var i,r,o,a,s,u;n&&!n.intersects(e.bounds)||(u=Tt(e.text))&&(i=null==e.opacity?1:e.opacity,0!==i&&(t.font=Mt(e),t.textAlign=e.align||"left",r=e.x||0,o=e.y||0,(a=e.radius)&&(s=(e.theta||0)-Math.PI/2,r+=a*Math.cos(s),o+=a*Math.sin(s)),e.angle&&(t.save(),t.translate(r,o),t.rotate(e.angle*Math.PI/180),r=o=0),r+=e.dx||0,o+=(e.dy||0)+zt(e),e.fill&&Ye(t,e,i)&&t.fillText(u,r,o),e.stroke&&Fe(t,e,i)&&t.strokeText(u,r,o),e.angle&&t.restore()))})}function St(t,e,n,i,r,o){if(e.fontSize<=0)return!1;if(!e.angle)return!0;var a=Pt(yn,e,!0),s=-e.angle*Math.PI/180,u=Math.cos(s),l=Math.sin(s),h=e.x,c=e.y,f=u*r-l*o+(h-h*u+c*l),d=l*r+u*o+(c-h*l-c*u);return a.contains(f,d)}function It(t,e){return JSON.stringify(t,wn,e)}function qt(t){var e="string"==typeof t?JSON.parse(t):t;return Rt(e)}function Rt(t){var e,n,i,r=t.marktype,o=t.items;if(o)for(n=0,i=o.length;n<i;++n)e=r?"mark":"group",o[n][e]=t,o[n].zindex&&(o[n][e].zdirty=!0),"group"===(r||e)&&Rt(o[n]);return r&&kn(t),t}function Lt(t){arguments.length?this.root=qt(t):(this.root=Et({marktype:"group",name:"root",role:"frame"}),this.root.items=[new a(this.root)])}function Ot(t){throw Error(t)}function Et(t,e){return{bounds:new r,bounds_prev:new r,clip:!!t.clip,group:e,interactive:t.interactive!==!1,items:[],marktype:t.marktype,name:t.name||void 0,role:t.role||void 0,zindex:t.zindex||0}}function Nt(t){this._active=null,this._handlers={},this._loader=t||e.loader()}function Dt(t){this._el=null,this._bgcolor=null,this._loader=new s(t)}function Ht(t,e,n){return n?t.createElementNS(n,e):t.createElement(e)}function Wt(t,e){e=e.toLowerCase();for(var n=t.childNodes,i=0,r=n.length;i<r;++i)if(n[i].tagName.toLowerCase()===e)return n[i]}function Gt(t,e,n,i){var r,o=t.childNodes[e];return o&&o.tagName.toLowerCase()===n.toLowerCase()||(r=o||null,o=Ht(t.ownerDocument,n,i),t.insertBefore(o,r)),o}function Vt(t,e){for(var n=t.childNodes,i=n.length;i>e;)t.removeChild(n[--i]);return t}function Bt(t){return"mark-"+t.marktype+(t.role?" role-"+t.role:"")+(t.name?" "+t.name:"")}function jt(t){Nt.call(this,t),this._down=null,this._touch=null,this._first=!0}function Ut(t,e,n){return function(i){var r=this._active,o=this.pickEvent(i);o===r?this.fire(t,i):(r&&r.exit||this.fire(n,i),this._active=o,this.fire(e,i),this.fire(t,i))}}function Jt(t){return function(e){this.fire(t,e),this._active=null}}function Xt(t){Dt.call(this,t),this._redraw=!1}function Qt(t,e){var n,i,o,a,s,u=new r;for(n=0,i=e.length;n<i;++n)o=e[n],a=o.mark,s=a.group,o=mn[a.marktype].nested?a:o,u.union($t(o.bounds,s)),o.bounds_prev&&u.union($t(o.bounds_prev,s));return u.round(),t.beginPath(),t.rect(u.x1,u.y1,u.width(),u.height()),t.clip(),u}function $t(t,e){if(null==e)return t;for(var n=Rn.clear().union(t);null!=e;e=e.mark.group)n.translate(e.x||0,e.y||0);return n}function Yt(t){Nt.call(this,t);var e=this;e._hrefHandler=Zt(e,function(t,n){n.href&&e.handleHref(t,n.href)})}function Zt(t,e){return function(n){var i=n.target,r=i.__data__;n.vegaType=n.type,r=Array.isArray(r)?r[0]:r,e.call(t._obj,n,r)}}function Ft(t,e,n){var i,r,o="<"+t;if(e)for(i in e)r=e[i],null!=r&&(o+=" "+i+'="'+r+'"');return n&&(o+=" "+n),o+">"}function Kt(t){return"</"+t+">"}function te(t){Dt.call(this,t),this._dirtyID=0,this._svg=null,this._root=null,this._defs=null}function ee(t,e,n){var i,r,o;for(t=Gt(t,n,"linearGradient",Dn),t.setAttribute("id",e.id),t.setAttribute("x1",e.x1),t.setAttribute("x2",e.x2),t.setAttribute("y1",e.y1),t.setAttribute("y2",e.y2),i=0,r=e.stops.length;i<r;++i)o=Gt(t,i,"stop",Dn),o.setAttribute("offset",e.stops[i].offset),o.setAttribute("stop-color",e.stops[i].color);Vt(t,i)}function ne(t,e,n){var i;t=Gt(t,n,"clipPath",Dn),t.setAttribute("id",e.id),i=Gt(t,0,"rect",Dn),i.setAttribute("x",0),i.setAttribute("y",0),i.setAttribute("width",e.width),i.setAttribute("height",e.height)}function ie(t,e){for(;t&&t.dirty!==e;t=t.mark.group){if(t.dirty=e,!t.mark||t.mark.dirty===e)return;t.mark.dirty=e}}function re(t,e,n){var i=e.firstChild,r=0;U(n,function(n){i=t.draw(e,n,i),++r}),Vt(e,1+r)}function oe(t,e,n,i){var r,o=t._svg;if(!o&&(r=e.ownerDocument,o=Ht(r,i,Dn),t._svg=o,t.mark&&(o.__data__=t,o.__values__={fill:"default"},"g"===i))){var a=Ht(r,"path",Dn);a.setAttribute("class","background"),o.appendChild(a),a.__data__=t}return(r||o.previousSibling!==n)&&e.insertBefore(o,n?n.nextSibling:e.firstChild),o}function ae(t,e,n){e!==Vn[t]&&(null!=e?n?Gn.setAttributeNS(n,t,e):Gn.setAttribute(t,e):n?Gn.removeAttributeNS(n,t):Gn.removeAttribute(t),Vn[t]=e)}function se(){return"undefined"!=typeof window?window.location.href:""}function ue(t){Dt.call(this,t),this._text={head:"",root:"",foot:"",defs:"",body:""},this._defs={clip_id:1,gradient:{},clipping:{}}}function le(t,e,n,i){Jn[i||t]=e}function he(t,e,n,i){if(null==t)return"";var r,o,a,s,u,l="";for("bgrect"===n&&e.interactive===!1&&(l+="pointer-events: none;"),"text"===n&&(l+="font: "+Mt(t)+";"),r=0,o=Nn.length;r<o;++r)a=Nn[r],s=En[a],u=t[a],null==u?"fill"===s&&(l+=(l.length?" ":"")+"fill: none;"):(u.id&&(i.gradient[u.id]=u,u="url(#"+u.id+")"),l+=(l.length?" ":"")+s+": "+u+";");return l?'style="'+l+'"':null}function ce(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var fe=r.prototype;fe.clone=function(){return new r(this)},fe.clear=function(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},fe.set=function(t,e,n,i){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),i<e?(this.y2=e,this.y1=i):(this.y1=e,this.y2=i),this},fe.add=function(t,e){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this},fe.expand=function(t){return this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t,this},fe.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},fe.translate=function(t,e){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this},fe.rotate=function(t,e,n){var i=Math.cos(t),r=Math.sin(t),o=e-e*i+n*r,a=n-e*r-n*i,s=this.x1,u=this.x2,l=this.y1,h=this.y2;return this.clear().add(i*s-r*l+o,r*s+i*l+a).add(i*s-r*h+o,r*s+i*h+a).add(i*u-r*l+o,r*u+i*l+a).add(i*u-r*h+o,r*u+i*h+a)},fe.union=function(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this},fe.encloses=function(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2},fe.alignsWith=function(t){return t&&(this.x1==t.x1||this.x2==t.x2||this.y1==t.y1||this.y2==t.y2)},fe.intersects=function(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)},fe.contains=function(t,e){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)},fe.width=function(){return this.x2-this.x1},fe.height=function(){return this.y2-this.y1};var de=0,ve=function(t,e){var n,i=[];return n={id:"gradient_"+de++,x1:t?t[0]:0,y1:t?t[1]:0,x2:e?e[0]:1,y2:e?e[1]:0,stops:i,stop:function(t,e){return i.push({offset:t,color:e}),n}}},ge=function(t,e){var n=t.prototype=Object.create(e.prototype);return n.constructor=t,n};ge(a,o);var pe;try{pe=require("canvas")}catch(t){pe=null}var ye=function(t,e){var n=null;return"undefined"!=typeof document&&document.createElement?(n=document.createElement("canvas"),n.width=t,n.height=e):pe&&(n=new pe(t,e)),n},_e="undefined"!=typeof Image?Image:pe&&pe.Image||null,me=s.prototype;me.pending=function(){return this._pending},me.sanitizeURL=function(t){var e=this;return u(e),e._loader.sanitize(t,{context:"href"}).then(function(t){return l(e),t}).catch(function(){return l(e),null})},me.loadImage=function(t){var e=this;return u(e),e._loader.sanitize(t,{context:"image"}).then(function(t){var n=t.href;if(!n||!_e)throw"Image unsupported.";var i=new _e;return i.onload=function(){l(e),i.loaded=!0},i.onerror=function(){l(e),i.loaded=!1},i.src=n,i}).catch(function(){return l(e),{loaded:!1,width:0,height:0}})},me.ready=function(){var t=this;return new Promise(function(e){function n(i){t.pending()?setTimeout(function(){n(!0)},10):e(i)}n(!1)})};var xe,be={basis:{curve:n.curveBasis},bundle:{curve:n.curveBundle,tension:"beta",value:.85},cardinal:{curve:n.curveCardinal,tension:"tension",value:0},catmullRom:{curve:n.curveCatmullRom,tension:"alpha",value:.5},linear:{curve:n.curveLinear},monotone:{horizontal:n.curveMonotoneY,vertical:n.curveMonotoneX},natural:{curve:n.curveNatural},step:{curve:n.curveStep},stepAfter:{curve:n.curveStepAfter},stepBefore:{curve:n.curveStepBefore}},ke={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},we=[/([MLHVCSQTAZmlhvcsqtaz])/g,/###/,/(\d)([-+])/g,/\s|,|###/],Te=function(t){var e,n,i,r,o,a,s,u,l,h,c,f=[];for(e=t.slice().replace(we[0],"###$1").split(we[1]).slice(1),u=0,h=e.length;u<h;++u){for(n=e[u],i=n.slice(1).trim().replace(we[2],"$1###$2").split(we[3]),a=n.charAt(0),r=[a],l=0,c=i.length;l<c;++l)(o=+i[l])===o&&r.push(o);if(s=ke[a.toLowerCase()],r.length-1>s)for(l=1,c=r.length;l<c;l+=s)f.push([a].concat(r.slice(l,l+s)));else f.push(r)}return f},Me={},ze={},Ae=[].join,Pe=["l",0,0,0,0,0,0,0],Ce=function(t,e,n,i,r){var o,a,s,u,l,h=null,c=0,f=0,g=0,p=0;null==n&&(n=0),null==i&&(i=0),null==r&&(r=1),t.beginPath&&t.beginPath();for(var y=0,_=e.length;y<_;++y){switch(o=e[y],1!==r&&(o=d(o,r)),o[0]){case"l":c+=o[1],f+=o[2],t.lineTo(c+n,f+i);break;case"L":c=o[1],f=o[2],t.lineTo(c+n,f+i);break;case"h":c+=o[1],t.lineTo(c+n,f+i);break;case"H":c=o[1],t.lineTo(c+n,f+i);break;case"v":f+=o[1],t.lineTo(c+n,f+i);break;case"V":f=o[1],t.lineTo(c+n,f+i);break;case"m":c+=o[1],f+=o[2],t.moveTo(c+n,f+i);break;case"M":c=o[1],f=o[2],t.moveTo(c+n,f+i);break;case"c":a=c+o[5],s=f+o[6],g=c+o[3],p=f+o[4],t.bezierCurveTo(c+o[1]+n,f+o[2]+i,g+n,p+i,a+n,s+i),c=a,f=s;break;case"C":c=o[5],f=o[6],g=o[3],p=o[4],t.bezierCurveTo(o[1]+n,o[2]+i,g+n,p+i,c+n,f+i);break;case"s":a=c+o[3],s=f+o[4],g=2*c-g,p=2*f-p,t.bezierCurveTo(g+n,p+i,c+o[1]+n,f+o[2]+i,a+n,s+i),g=c+o[1],p=f+o[2],c=a,f=s;break;case"S":a=o[3],s=o[4],g=2*c-g,p=2*f-p,t.bezierCurveTo(g+n,p+i,o[1]+n,o[2]+i,a+n,s+i),c=a,f=s,g=o[1],p=o[2];break;case"q":a=c+o[3],s=f+o[4],g=c+o[1],p=f+o[2],t.quadraticCurveTo(g+n,p+i,a+n,s+i),c=a,f=s;break;case"Q":a=o[3],s=o[4],t.quadraticCurveTo(o[1]+n,o[2]+i,a+n,s+i),c=a,f=s,g=o[1],p=o[2];break;case"t":a=c+o[1],s=f+o[2],null===h[0].match(/[QqTt]/)?(g=c,p=f):"t"===h[0]?(g=2*c-u,p=2*f-l):"q"===h[0]&&(g=2*c-g,p=2*f-p),u=g,l=p,t.quadraticCurveTo(g+n,p+i,a+n,s+i),c=a,f=s,g=c+o[1],p=f+o[2];break;case"T":a=o[1],s=o[2],g=2*c-g,p=2*f-p,t.quadraticCurveTo(g+n,p+i,a+n,s+i),c=a,f=s;break;case"a":v(t,c+n,f+i,[o[1],o[2],o[3],o[4],o[5],o[6]+c+n,o[7]+f+i]),c+=o[6],f+=o[7];break;case"A":v(t,c+n,f+i,[o[1],o[2],o[3],o[4],o[5],o[6]+n,o[7]+i]),c=o[6],f=o[7];break;case"z":case"Z":t.closePath()}h=o}},Se=2*Math.PI,Ie=Math.sqrt(3)/2,qe={circle:{draw:function(t,e){var n=Math.sqrt(e)/2;t.moveTo(n,0),t.arc(0,0,n,0,Se)}},cross:{draw:function(t,e){var n=Math.sqrt(e)/2,i=n/2.5;t.moveTo(-n,-i),t.lineTo(-n,i),t.lineTo(-i,i),t.lineTo(-i,n),t.lineTo(i,n),t.lineTo(i,i),t.lineTo(n,i),t.lineTo(n,-i),t.lineTo(i,-i),t.lineTo(i,-n),t.lineTo(-i,-n),t.lineTo(-i,-i),t.closePath()}},diamond:{draw:function(t,e){var n=Math.sqrt(e)/2;t.moveTo(-n,0),t.lineTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.closePath()}},square:{draw:function(t,e){var n=Math.sqrt(e),i=-n/2;t.rect(i,i,n,n)}},"triangle-up":{draw:function(t,e){var n=Math.sqrt(e)/2,i=Ie*n;t.moveTo(0,-i),t.lineTo(-n,i),t.lineTo(n,i),t.closePath()}},"triangle-down":{draw:function(t,e){var n=Math.sqrt(e)/2,i=Ie*n;t.moveTo(0,i),t.lineTo(-n,-i),t.lineTo(n,-i),t.closePath()}},"triangle-right":{draw:function(t,e){var n=Math.sqrt(e)/2,i=Ie*n;t.moveTo(i,0),t.lineTo(-i,-n),t.lineTo(-i,n),t.closePath()}},"triangle-left":{draw:function(t,e){var n=Math.sqrt(e)/2,i=Ie*n;t.moveTo(-i,0),t.lineTo(i,-n),t.lineTo(i,n),t.closePath()}}},Re={},Le=function(){function t(t,u,l){var h,c=null!=u?u:+e.call(this,t),f=null!=l?l:+n.call(this,t),d=+r.call(this,t),v=+o.call(this,t),g=+a.call(this,t);if(s||(s=h=i.path()),g<=0)s.rect(c,f,d,v);else{var p=c+d,y=f+v;s.moveTo(c+g,f),s.lineTo(p-g,f),s.quadraticCurveTo(p,f,p,f+g),s.lineTo(p,y-g),s.quadraticCurveTo(p,y,p-g,y),s.lineTo(c+g,y),s.quadraticCurveTo(c,y,c,y-g),s.lineTo(c,f+g),s.quadraticCurveTo(c,f,c+g,f),s.closePath()}if(h)return s=null,h+""||null}var e=y,n=_,r=m,o=x,a=b(0),s=null;return t.x=function(n){return arguments.length?(e="function"==typeof n?n:b(+n),t):e},t.y=function(e){return arguments.length?(n="function"==typeof e?e:b(+e),t):n},t.width=function(e){return arguments.length?(r="function"==typeof e?e:b(+e),t):r},t.height=function(e){return arguments.length?(o="function"==typeof e?e:b(+e),t):o},t.cornerRadius=function(e){return arguments.length?(a="function"==typeof e?e:b(+e),t):a},t.context=function(e){return arguments.length?(s=null==e?null:e,t):s},t},Oe=Math.PI,Ee=function(){function t(t,e,n){var i=n/2;if(s){var r=l-e,o=t-u,a=Math.sqrt(r*r+o*o),f=(r/=a)*h,d=(o/=a)*h,v=Math.atan2(o,r);c.moveTo(u-f,l-d),c.lineTo(t-r*i,e-o*i),c.arc(t,e,i,v-Oe,v),c.lineTo(u+f,l+d),c.arc(u,l,h,v,v+Oe),c.closePath()}else s=1;u=t,l=e,h=i}function e(e){var u,l,h,f=e.length,d=!1;for(null==c&&(c=h=i.path()),u=0;u<=f;++u)!(u<f&&a(l=e[u],u,e))===d&&(d=!d)&&(s=0),d&&t(+n(l,u,e),+r(l,u,e),+o(l,u,e));if(h)return c=null,h+""||null}var n,r,o,a,s,u,l,h,c=null;return e.x=function(t){return arguments.length?(n=t,e):n},e.y=function(t){return arguments.length?(r=t,e):r},e.size=function(t){return arguments.length?(o=t,e):o},e.defined=function(t){return arguments.length?(a=t,e):a},e.context=function(t){return arguments.length?(c=null==t?null:t,e):c},e},Ne=n.arc().cornerRadius(C).padAngle(S),De=n.area().x(k).y1(w).y0(P).defined(I),He=n.area().y(w).x1(k).x0(A).defined(I),We=n.line().x(k).y(w).defined(I),Ge=Ee().x(k).y(w).defined(I).size(M),Ve=Le().x(k).y(w).width(T).height(z).cornerRadius(C),Be=n.symbol().type(R).size(q),je=function(t,e){return e.stroke&&0!==e.opacity&&0!==e.stokeOpacity&&t.expand(null!=e.strokeWidth?+e.strokeWidth:1),t},Ue=2*Math.PI,Je=Math.PI/2;W.beginPath=G,W.closePath=G,W.moveTo=V,W.lineTo=V,W.rect=function(t,e,n,i){V(t,e),V(t+n,e+i)},W.quadraticCurveTo=function(t,e,n,i){V(t,e),V(n,i)},W.bezierCurveTo=function(t,e,n,i,r,o){V(t,e),V(n,i),V(r,o)},W.arc=function(t,e,n,i,r,o){function a(t){l=n*Math.cos(t),h=n*Math.sin(t),l<c&&(c=l),l>f&&(f=l),h<d&&(d=h),h>v&&(v=h)}if(n===Ue)return V(t-n,e-n),void V(t+n,e+n);var s,u,l,h,c=1/0,f=-(1/0),d=1/0,v=-(1/0);if(a(i),a(r),o)for(s=r-r%Je,u=0;u<4&&s>i;++u,s-=Je)a(s);else for(s=i-i%Je,u=0;u<4&&s<r;++u,s+=Je)a(s);V(t+c,e+d),V(t+f,e+v)};var Xe,Qe=function(t,e,n){for(var i=n.width(),r=n.height(),o=n.x1+e.x1*i,a=n.y1+e.y1*r,s=n.x1+e.x2*i,u=n.y1+e.y2*r,l=e.stops,h=0,c=l.length,f=t.createLinearGradient(o,a,s,u);h<c;++h)f.addColorStop(l[h].offset,l[h].color);return f},$e=function(t,e,n){return n.id?Qe(t,n,e.bounds):n},Ye=function(t,e,n){return n*=null==e.fillOpacity?1:e.fillOpacity,n>0&&(t.globalAlpha=n,t.fillStyle=$e(t,e,e.fill),!0)},Ze=[],Fe=function(t,e,n){var i,r=null!=(r=e.strokeWidth)?r:1;return!(r<=0)&&(n*=null==e.strokeOpacity?1:e.strokeOpacity,n>0&&(t.globalAlpha=n,t.strokeStyle=$e(t,e,e.stroke),t.lineWidth=r,t.lineCap=null!=(i=e.strokeCap)?i:"butt",t.setLineDash&&(t.setLineDash(e.strokeDash||Ze),t.lineDashOffset=e.strokeDashOffset||0),!0))},Ke=function(){return!0},tn=function(t,e){return"translate("+t+","+e+")"},en=function(t){return tn(t.x||0,t.y||0)},nn=function(t,e){function n(t,n){t("transform",en(n)),t("d",e(null,n))}function i(t,n){return e(W(t),n),je(t,n).translate(n.x||0,n.y||0)}function r(t,n){var i=n.x||0,r=n.y||0;t.translate(i,r),t.beginPath(),e(t,n),t.translate(-i,-r)}return{type:t,tag:"path",nested:!1,attr:n,bound:i,draw:X(r),pick:F(r)}},rn=nn("arc",L),on=function(t,e){function n(t,n){var i=n.mark.items;i.length&&t("d",e(null,i))}function i(t,n){var i=n.items;return 0===i.length?t:(e(W(t),i),je(t,i[0]))}function r(t,n){t.beginPath(),e(t,n)}function o(t,e,n,i,r,o){var s=e.items,u=e.bounds;return!s||!s.length||u&&!u.contains(r,o)?null:(t.pixelRatio>1&&(n*=t.pixelRatio,i*=t.pixelRatio),a(t,s,n,i)?s[0]:null)}var a=Z(r);return{type:t,tag:"path",nested:!0,attr:n,bound:i,draw:Q(r),pick:o}},an=on("area",O),sn={type:"group",tag:"g",nested:!1,attr:K,bound:et,draw:nt,pick:it,background:tt},un={type:"image",tag:"image",nested:!1,attr:st,bound:ut,draw:lt,pick:Y()},ln=on("line",N),hn={type:"path",tag:"path",nested:!1,attr:ht,bound:ft,draw:X(ct),pick:F(ct)},cn={type:"rect",tag:"path",nested:!1,attr:dt,bound:vt,draw:X(gt),pick:F(gt)},fn={type:"rule",tag:"line",nested:!1,attr:pt,bound:yt,draw:mt,pick:Y(xt)},dn=nn("shape",E),vn=nn("symbol",H),gn={height:wt,measureWidth:kt,estimateWidth:bt,width:(Xe=ye(1,1))?(Xe=Xe.getContext("2d"),kt):bt},pn={left:"start",center:"middle",right:"end"},yn=new r,_n={type:"text",tag:"text",nested:!1,attr:At,bound:Pt,draw:Ct,pick:Y(St)},mn={arc:rn,area:an,group:sn,image:un,line:ln,path:hn,rect:cn,rule:fn,shape:dn,symbol:vn,text:_n},xn=function(t,e,n){var i=mn[t.mark.marktype],o=e||i.bound;i.nested&&(t=t.mark);var a=t.bounds,s=t.bounds_prev||(t.bounds_prev=new r);return a?(s.clear().union(a),a.clear()):t.bounds=new r,o(t.bounds,t,n),a||s.clear().union(t.bounds),t.bounds},bn={mark:null},kn=function(t,e,n){var i,o,a,s,u=mn[t.marktype],l=u.bound,h=t.items,c=h&&h.length;if(u.nested)return a=c?h[0]:(bn.mark=t,bn),s=xn(a,l,n),e=e&&e.union(s)||s;if(e=e||t.bounds&&t.bounds.clear()||new r,c)for(i=0,o=h.length;i<o;++i)e.union(xn(h[i],l,n));return t.bounds=e},wn=["marktype","name","role","interactive","clip","items","zindex","x","y","width","height","align","baseline","fill","fillOpacity","opacity","stroke","strokeOpacity","strokeWidth","strokeCap","strokeDash","strokeDashOffset","startAngle","endAngle","innerRadius","outerRadius","cornerRadius","padAngle","interpolate","tension","orient","defined","url","path","x2","y2","size","shape","text","angle","theta","radius","dx","dy","font","fontSize","fontWeight","fontStyle","fontVariant"],Tn=Lt.prototype;Tn.toJSON=function(t){return It(this.root,t||0)},Tn.mark=function(t,e){var n,i,r,o,a=t.marks,s=t.items,u=this.root.items[0];try{for(r=0,o=a.length;r<o&&(n=u.items[a[r]],n);++r)i=s[r]||0,u=n.items[i]||n.items[n.items.length-1];if(!n)return n=Et(e,u),u.items[a[r]]=n,n.zindex&&(n.group.zdirty=!0),n;throw o}catch(e){Ot("Invalid scenegraph path: "+JSON.stringify(t))}};var Mn=Nt.prototype;Mn.initialize=function(t,e,n){return this._el=t,this._obj=n||null,this.origin(e)},Mn.element=function(){return this._el},Mn.origin=function(t){return this._origin=t||[0,0],this},Mn.scene=function(t){return arguments.length?(this._scene=t,this):this._scene},Mn.on=function(){},Mn.off=function(){},Mn.handlers=function(){var t,e=this._handlers,n=[];for(t in e)n.push.apply(n,e[t]);return n},Mn.eventName=function(t){var e=t.indexOf(".");return e<0?t:t.slice(0,e)},Mn.handleHref=function(t,e){"undefined"!=typeof MouseEvent&&"undefined"!=typeof document&&document.createElement&&this._loader.sanitize(e,{context:"href"}).then(function(e){var n=document.createElement("a");for(var i in e)n.setAttribute(i,e[i]);n.dispatchEvent(new MouseEvent(t.type,t))}).catch(function(){})};var zn=Dt.prototype;zn.initialize=function(t,e,n,i){return this._el=t,this.resize(e,n,i)},zn.element=function(){return this._el},zn.scene=function(){return this._el&&this._el.firstChild},zn.background=function(t){return 0===arguments.length?this._bgcolor:(this._bgcolor=t,this)},zn.resize=function(t,e,n){return this._width=t,this._height=e,this._origin=n||[0,0],this},zn.render=function(t,e){var n=this;return n._call=function(){n._render(t,e)},n._call(),n._call=null,n},zn._render=function(){},zn.renderAsync=function(t,e){var n=this.render(t,e);return this._ready?this._ready.then(function(){return n}):Promise.resolve(n)},zn._load=function(t,e){var n=this,i=n._loader[t](e);if(!n._ready){var r=n._call;n._ready=n._loader.ready().then(function(t){t&&r(),n._ready=null})}return i},zn.sanitizeURL=function(t){return this._load("sanitizeURL",t)},zn.loadImage=function(t){return this._load("loadImage",t)};var An=function(t,e){var n=e.getBoundingClientRect();return[t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0)]},Pn=ge(jt,Nt);Pn.initialize=function(t,e,n){var i=this._canvas=t&&Wt(t,"canvas");if(i){var r=this;this.events.forEach(function(t){i.addEventListener(t,function(e){Pn[t]?Pn[t].call(r,e):r.fire(t,e)})})}return Nt.prototype.initialize.call(this,t,e,n)},Pn.canvas=function(){return this._canvas},Pn.context=function(){return this._canvas.getContext("2d")},Pn.events=["keydown","keypress","keyup","dragenter","dragleave","dragover","mousedown","mouseup","mousemove","mouseout","mouseover","click","dblclick","wheel","mousewheel","touchstart","touchmove","touchend"],Pn.DOMMouseScroll=function(t){this.fire("mousewheel",t)},Pn.mousemove=Ut("mousemove","mouseover","mouseout"),Pn.dragover=Ut("dragover","dragenter","dragleave"),Pn.mouseout=Jt("mouseout"),Pn.dragleave=Jt("dragleave"),Pn.mousedown=function(t){this._down=this._active,this.fire("mousedown",t)},Pn.click=function(t){this._down===this._active&&(this.fire("click",t),this._down=null)},Pn.touchstart=function(t){this._touch=this.pickEvent(t.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire("touchstart",t,!0)},Pn.touchmove=function(t){this.fire("touchmove",t,!0)},Pn.touchend=function(t){this.fire("touchend",t,!0),this._touch=null},Pn.fire=function(t,e,n){var i,r,o=n?this._touch:this._active,a=this._handlers[t];if("click"===t&&o&&o.href&&this.handleHref(e,o.href),a)for(e.vegaType=t,i=0,r=a.length;i<r;++i)a[i].handler.call(this._obj,e,o)},Pn.on=function(t,e){var n=this.eventName(t),i=this._handlers;return(i[n]||(i[n]=[])).push({type:t,handler:e}),this},Pn.off=function(t,e){var n,i=this.eventName(t),r=this._handlers[i];if(r){for(n=r.length;--n>=0;)r[n].type===t&&(e&&r[n].handler!==e||r.splice(n,1));return this}},Pn.pickEvent=function(t){var e=An(t,this._canvas),n=this._origin;return this.pick(this._scene,e[0],e[1],e[0]-n[0],e[1]-n[1])},Pn.pick=function(t,e,n,i,r){var o=this.context(),a=mn[t.marktype];return a.pick.call(this,o,t,e,n,i,r)};var Cn="undefined"!=typeof window?window.devicePixelRatio||1:1,Sn=function(t,e,n,i){var r="undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&null!=t.parentNode,o=t.getContext("2d"),a=r?Cn:1;return t.width=e*a,t.height=n*a,1!==a&&(t.style.width=e+"px",t.style.height=n+"px"),o.pixelRatio=a,o.setTransform(a,0,0,a,a*i[0],a*i[1]),t},In=ge(Xt,Dt),qn=Dt.prototype,Rn=new r;In.initialize=function(t,e,n,i){return this._canvas=ye(1,1),t&&(Vt(t,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),qn.initialize.call(this,t,e,n,i)},In.resize=function(t,e,n){return qn.resize.call(this,t,e,n),Sn(this._canvas,this._width,this._height,this._origin),
this._redraw=!0,this},In.canvas=function(){return this._canvas},In.context=function(){return this._canvas?this._canvas.getContext("2d"):null},In._render=function(t,e){var n,i=this.context(),r=this._origin,o=this._width,a=this._height;return i.save(),n=!e||this._redraw?(this._redraw=!1,null):Qt(i,e),this.clear(-r[0],-r[1],o,a),this.draw(i,t,n),i.restore(),this},In.draw=function(t,e,n){var i=mn[e.marktype];i.draw.call(this,t,e,n)},In.clear=function(t,e,n,i){var r=this.context();r.clearRect(t,e,n,i),null!=this._bgcolor&&(r.fillStyle=this._bgcolor,r.fillRect(t,e,n,i))};var Ln=ge(Yt,Nt);Ln.initialize=function(t,e,n){return this._svg&&this._svg.removeEventListener("click",this._hrefHandler),this._svg=t&&Wt(t,"svg"),this._svg&&this._svg.addEventListener("click",this._hrefHandler),Nt.prototype.initialize.call(this,t,e,n)},Ln.svg=function(){return this._svg},Ln.on=function(t,e){var n=this.eventName(t),i=this._handlers,r={type:t,handler:e,listener:Zt(this,e)};return(i[n]||(i[n]=[])).push(r),this._svg&&this._svg.addEventListener(n,r.listener),this},Ln.off=function(t,e){var n,i=this.eventName(t),r=this._svg,o=this._handlers[i];if(o){for(n=o.length;--n>=0;)(o[n].type===t&&!e||o[n].handler===e)&&(this._svg&&r.removeEventListener(i,o[n].listener),o.splice(n,1));return this}};var On={version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},En={fill:"fill",fillOpacity:"fill-opacity",stroke:"stroke",strokeWidth:"stroke-width",strokeOpacity:"stroke-opacity",strokeCap:"stroke-linecap",strokeDash:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",opacity:"opacity"},Nn=Object.keys(En),Dn=On.xmlns,Hn=ge(te,Dt),Wn=Dt.prototype;Hn.initialize=function(t,e,n,i){return t&&(this._svg=Gt(t,0,"svg",Dn),this._svg.setAttribute("class","marks"),Vt(t,1),this._root=Gt(this._svg,0,"g",Dn),Vt(this._svg,1)),this._defs={clip_id:1,gradient:{},clipping:{}},this.background(this._bgcolor),Wn.initialize.call(this,t,e,n,i)},Hn.background=function(t){return arguments.length&&this._svg&&this._svg.style.setProperty("background-color",t),Wn.background.apply(this,arguments)},Hn.resize=function(t,e,n){return Wn.resize.call(this,t,e,n),this._svg&&(this._svg.setAttribute("width",this._width),this._svg.setAttribute("height",this._height),this._svg.setAttribute("viewBox","0 0 "+this._width+" "+this._height),this._root.setAttribute("transform","translate("+this._origin+")")),this},Hn.svg=function(){if(!this._svg)return null;var t={class:"marks",width:this._width,height:this._height,viewBox:"0 0 "+this._width+" "+this._height};for(var e in On)t[e]=On[e];return Ft("svg",t)+this._svg.innerHTML+Kt("svg")},Hn._render=function(t,e){return this._dirtyCheck(e)&&(this._dirtyAll&&this._resetDefs(),this.draw(this._root,t),Vt(this._root,1)),this.updateDefs(),this},Hn.updateDefs=function(){var t,e=this._svg,n=this._defs,i=n.el,r=0;for(t in n.gradient)i||(n.el=i=Gt(e,0,"defs",Dn)),ee(i,n.gradient[t],r++);for(t in n.clipping)i||(n.el=i=Gt(e,0,"defs",Dn)),ne(i,n.clipping[t],r++);i&&(0===r?(e.removeChild(i),n.el=null):Vt(i,r))},Hn._resetDefs=function(){var t=this._defs;t.clip_id=1,t.gradient={},t.clipping={}},Hn.isDirty=function(t){return this._dirtyAll||!t._svg||t.dirty===this._dirtyID},Hn._dirtyCheck=function(t){if(this._dirtyAll=!0,!t)return!0;var e,n,i,r,o,a,s,u=++this._dirtyID;for(o=0,a=t.length;o<a;++o)e=t[o],n=e.mark,n.marktype!==i&&(i=n.marktype,r=mn[i]),n.zdirty&&n.dirty!==u&&(this._dirtyAll=!1,n.dirty=u,ie(n.group,u)),e.exit?(r.nested&&n.items.length?(s=n.items[0],s._svg&&this._update(r,s._svg,s)):e._svg&&e._svg.remove(),e._svg=null):(e=r.nested?n.items[0]:e,e._update!==u&&(e._svg&&e._svg.ownerSVGElement?this._update(r,e._svg,e):(this._dirtyAll=!1,ie(e,u)),e._update=u));return!this._dirtyAll},Hn.draw=function(t,e,n){function i(t){var e=o.isDirty(t),n=oe(t,r,l,a.tag);e&&(o._update(a,n,t),u&&re(o,n,t)),l=n,++h}if(!this.isDirty(e))return e._svg;var r,o=this,a=mn[e.marktype],s=e.interactive===!1?"none":null,u="g"===a.tag,l=null,h=0;return r=oe(e,t,n,"g"),r.setAttribute("class",Bt(e)),!u&&s&&r.style.setProperty("pointer-events",s),a.nested?e.items.length&&i(e.items[0]):U(e,i),Vt(r,h),r};var Gn=null,Vn=null,Bn={group:function(t,e,n){Gn=e.childNodes[0],Vn=e.__values__,t.background(ae,n,this);var i=n.mark.interactive===!1?"none":null;i!==Vn.events&&(Gn.style.setProperty("pointer-events",i),Vn.events=i)},text:function(t,e,n){var i=Tt(n.text);i!==Vn.text&&(e.textContent=i,Vn.text=i),i=Mt(n),i!==Vn.font&&(e.style.setProperty("font",i),Vn.font=i)}};Hn._update=function(t,e,n){Gn=e,Vn=e.__values__,t.attr(ae,n,this);var i=Bn[t.type];i&&i(t,e,n),this.style(Gn,n)},Hn.style=function(t,e){if(null!=e){var n,i,r,o,a;for(n=0,i=Nn.length;n<i;++n)r=Nn[n],a=e[r],a!==Vn[r]&&(o=En[r],null==a?"fill"===o?t.style.setProperty(o,"none"):t.style.removeProperty(o):(a.id&&(this._defs.gradient[a.id]=a,a="url("+se()+"#"+a.id+")"),t.style.setProperty(o,a+"")),Vn[r]=a)}};var jn=ge(ue,Dt),Un=Dt.prototype;jn.resize=function(t,e,n){Un.resize.call(this,t,e,n);var i=this._origin,r=this._text,o={class:"marks",width:this._width,height:this._height,viewBox:"0 0 "+this._width+" "+this._height};for(var a in On)o[a]=On[a];return r.head=Ft("svg",o),r.root=Ft("g",{transform:"translate("+i+")"}),r.foot=Kt("g")+Kt("svg"),this},jn.svg=function(){var t=this._text;return t.head+t.defs+t.root+t.body+t.foot},jn._render=function(t){return this._text.body=this.mark(t),this._text.defs=this.buildDefs(),this},jn.reset=function(){return this._defs.clip_id=0,this},jn.buildDefs=function(){var t,e,n,i,r=this._defs,o="";for(e in r.gradient){for(n=r.gradient[e],i=n.stops,o+=Ft("linearGradient",{id:e,x1:n.x1,x2:n.x2,y1:n.y1,y2:n.y2}),t=0;t<i.length;++t)o+=Ft("stop",{offset:i[t].offset,"stop-color":i[t].color})+Kt("stop");o+=Kt("linearGradient")}for(e in r.clipping)n=r.clipping[e],o+=Ft("clipPath",{id:e}),o+=Ft("rect",{x:0,y:0,width:n.width,height:n.height})+Kt("rect"),o+=Kt("clipPath");return o.length>0?Ft("defs")+o+Kt("defs"):""};var Jn;jn.attributes=function(t,e){return Jn={},t(le,e,this),Jn},jn.href=function(t){var e,n=this,i=t.href;if(i){if(e=n._hrefs&&n._hrefs[i])return e;n.sanitizeURL(i).then(function(t){t["xlink:href"]=t.href,t.href=null,(n._hrefs||(n._hrefs={}))[i]=t})}return null},jn.mark=function(t){function e(e){var u=i.href(e);u&&(s+=Ft("a",u)),n="g"!==o?he(e,t,o,a):null,s+=Ft(o,i.attributes(r.attr,e),n),"text"===o?s+=ce(Tt(e.text)):"g"===o&&(s+=Ft("path",i.attributes(r.background,e),he(e,t,"bgrect",a))+Kt("path"),s+=i.markGroup(e)),s+=Kt(o),u&&(s+=Kt("a"))}var n,i=this,r=mn[t.marktype],o=r.tag,a=this._defs,s="";return"g"!==o&&t.interactive===!1&&(n='style="pointer-events: none;"'),s+=Ft("g",{class:Bt(t)},n),r.nested?t.items&&t.items.length&&e(t.items[0]):U(t,e),s+Kt("g")},jn.markGroup=function(t){var e=this,n="";return U(t,function(t){n+=e.mark(t)}),n};var Xn=function(t,e,n,i){var r,o,a,s=ve(e,n),u=t.domain(),l=u[0],h=u[u.length-1];for("linear"!==t.type&&t.ticks&&(u=t.ticks(+i||15),l!==u[0]&&u.unshift(l),h!==u[u.length-1]&&u.push(h)),a=t.range?t.copy().domain([l,h]).range([0,1]):function(t){return(t-l)/(h-l)},r=0,o=u.length;r<o;++r)s.stop(a(u[r]),t(u[r]));return s};t.Bounds=r,t.Gradient=ve,t.GroupItem=a,t.ResourceLoader=s,t.Item=o,t.Scenegraph=Lt,t.Handler=Nt,t.Renderer=Dt,t.CanvasHandler=jt,t.CanvasRenderer=Xt,t.SVGHandler=Yt,t.SVGRenderer=te,t.SVGStringRenderer=ue,t.boundContext=W,t.boundStroke=je,t.boundItem=xn,t.boundMark=kn,t.Marks=mn,t.pathParse=Te,t.pathRender=Ce,t.scaleGradient=Xn,t.point=An,t.canvas=ye,t.openTag=Ft,t.closeTag=Kt,t.font=Mt,t.textMetrics=gn,t.toJSON=It,t.fromJSON=qt,Object.defineProperty(t,"__esModule",{value:!0})});
export {default as Bounds} from './src/Bounds';
export {default as Gradient} from './src/Gradient';
export {default as GroupItem} from './src/GroupItem';
export {default as ImageLoader} from './src/ImageLoader';
export {default as ResourceLoader} from './src/ResourceLoader';
export {default as Item} from './src/Item';

@@ -6,0 +6,0 @@ export {default as Scenegraph} from './src/Scenegraph';

{
"name": "vega-scenegraph",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.6",
"description": "Vega scenegraph and renderers.",

@@ -37,3 +37,3 @@ "license": "BSD-3-Clause",

"d3-shape": "1",
"vega-loader": ">=2.0.0-beta"
"vega-loader": ">=2.0.0-beta.3"
},

@@ -40,0 +40,0 @@ "optionalDependencies": {

@@ -7,4 +7,4 @@ import Handler from './Handler';

export default function CanvasHandler() {
Handler.call(this);
export default function CanvasHandler(loader) {
Handler.call(this, loader);
this._down = null;

@@ -67,3 +67,3 @@ this._touch = null;

// to keep firefox happy
// to keep old versions of firefox happy
prototype.DOMMouseScroll = function(evt) {

@@ -144,2 +144,9 @@ this.fire('mousewheel', evt);

h = this._handlers[type], i, len;
// if hyperlinked, handle link first
if (type === 'click' && a && a.href) {
this.handleHref(evt, a.href);
}
// invoke all registered handlers
if (h) {

@@ -146,0 +153,0 @@ evt.vegaType = type;

@@ -10,4 +10,4 @@ import Renderer from './Renderer';

export default function CanvasRenderer(imageLoader) {
Renderer.call(this, imageLoader);
export default function CanvasRenderer(loader) {
Renderer.call(this, loader);
this._redraw = false;

@@ -14,0 +14,0 @@ }

@@ -1,4 +0,7 @@

export default function Handler() {
import {loader} from 'vega-loader';
export default function Handler(customLoader) {
this._active = null;
this._handlers = {};
this._loader = customLoader || loader();
}

@@ -48,1 +51,16 @@

};
prototype.handleHref = function(event, href) {
if (typeof MouseEvent !== 'undefined' &&
typeof document !== 'undefined' && document.createElement)
{
this._loader
.sanitize(href, {context:'href'})
.then(function(opt) {
var a = document.createElement('a');
for (var name in opt) a.setAttribute(name, opt[name]);
a.dispatchEvent(new MouseEvent(event.type, event));
})
.catch(function() { /* do nothing */ });
}
};

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

import ImageLoader from './ImageLoader';
import ResourceLoader from './ResourceLoader';
/**
* Create a new Renderer instance.
* @param {object} [imageLoader] - Optional loader instance for
* image URL sanitization. If not specified, a standard loader
* instance will be generated.
* @param {object} [loader] - Optional loader instance for
* image and href URL sanitization. If not specified, a
* standard loader instance will be generated.
* @constructor
*/
export default function Renderer(imageLoader) {
export default function Renderer(loader) {
this._el = null;
this._bgcolor = null;
this._loader = new ImageLoader(imageLoader);
this._loader = new ResourceLoader(loader);
}

@@ -131,14 +131,15 @@

/**
* Requests an image to include in the rendered scene.
* This method proxies a call to ImageLoader.loadImage, but also tracks
* image loading progress and invokes a re-render once complete.
* @return {Image} - The requested image instance.
* The image content may not be loaded yet.
* Internal method for asynchronous resource loading.
* Proxies method calls to the ImageLoader, and tracks loading
* progress to invoke a re-render once complete.
* @param {string} method - The method name to invoke on the ImageLoader.
* @param {string} uri - The URI for the requested resource.
* @return {Promise} - A Promise that resolves to the requested resource.
*/
prototype.loadImage = function(uri) {
prototype._load = function(method, uri) {
var r = this,
p = r._loader.loadImage(uri);
p = r._loader[method](uri);
if (!r._ready) {
// re-render the scene when image loading completes
// re-render the scene when loading completes
var call = r._call;

@@ -154,1 +155,23 @@ r._ready = r._loader.ready()

};
/**
* Sanitize a URL to include as a hyperlink in the rendered scene.
* This method proxies a call to ImageLoader.sanitizeURL, but also tracks
* image loading progress and invokes a re-render once complete.
* @param {string} uri - The URI string to sanitize.
* @return {Promise} - A Promise that resolves to the sanitized URL.
*/
prototype.sanitizeURL = function(uri) {
return this._load('sanitizeURL', uri);
};
/**
* Requests an image to include in the rendered scene.
* This method proxies a call to ImageLoader.loadImage, but also tracks
* image loading progress and invokes a re-render once complete.
* @param {string} uri - The URI string of the image.
* @return {Promise} - A Promise that resolves to the loaded Image.
*/
prototype.loadImage = function(uri) {
return this._load('loadImage', uri);
};

@@ -5,4 +5,8 @@ import Handler from './Handler';

export default function SVGHandler() {
Handler.call(this);
export default function SVGHandler(loader) {
Handler.call(this, loader);
var h = this;
h._hrefHandler = listener(h, function(evt, item) {
if (item.href) h.handleHref(evt, item.href);
});
}

@@ -13,3 +17,5 @@

prototype.initialize = function(el, origin, obj) {
if (this._svg) this._svg.removeEventListener('click', this._hrefHandler);
this._svg = el && find(el, 'svg');
if (this._svg) this._svg.addEventListener('click', this._hrefHandler);
return Handler.prototype.initialize.call(this, el, origin, obj);

@@ -23,4 +29,3 @@ };

// wrap an event listener for the SVG DOM
prototype.listener = function(handler) {
var that = this;
function listener(context, handler) {
return function(evt) {

@@ -31,5 +36,5 @@ var target = evt.target,

item = Array.isArray(item) ? item[0] : item;
handler.call(that._obj, evt, item);
handler.call(context._obj, evt, item);
};
};
}

@@ -43,3 +48,3 @@ // add an event handler

handler: handler,
listener: this.listener(handler)
listener: listener(this, handler)
};

@@ -46,0 +51,0 @@

@@ -13,4 +13,4 @@ import Renderer from './Renderer';

export default function SVGRenderer(imageLoader) {
Renderer.call(this, imageLoader);
export default function SVGRenderer(loader) {
Renderer.call(this, loader);
this._dirtyID = 0;

@@ -61,2 +61,3 @@ this._svg = null;

this._svg.setAttribute('height', this._height);
this._svg.setAttribute('viewBox', '0 0 ' + this._width + ' ' + this._height);
this._root.setAttribute('transform', 'translate(' + this._origin + ')');

@@ -74,3 +75,4 @@ }

'width': this._width,
'height': this._height
'height': this._height,
'viewBox': '0 0 ' + this._width + ' ' + this._height
};

@@ -77,0 +79,0 @@ for (var key in metadata) {

@@ -11,4 +11,4 @@ import Renderer from './Renderer';

export default function SVGStringRenderer(imageLoader) {
Renderer.call(this, imageLoader);
export default function SVGStringRenderer(loader) {
Renderer.call(this, loader);

@@ -41,3 +41,4 @@ this._text = {

'width': this._width,
'height': this._height
'height': this._height,
'viewBox': '0 0 ' + this._width + ' ' + this._height
};

@@ -130,2 +131,23 @@ for (var key in metadata) {

prototype.href = function(item) {
var that = this,
href = item.href,
attr;
if (href) {
if (attr = that._hrefs && that._hrefs[href]) {
return attr;
} else {
that.sanitizeURL(href).then(function(attr) {
// rewrite to use xlink namespace
// note that this will be deprecated in SVG 2.0
attr['xlink:href'] = attr.href;
attr.href = null;
(that._hrefs || (that._hrefs = {}))[href] = attr;
});
}
}
return null;
};
prototype.mark = function(scene) {

@@ -150,2 +172,5 @@ var renderer = this,

function process(item) {
var href = renderer.href(item);
if (href) str += openTag('a', href);
style = (tag !== 'g') ? applyStyles(item, scene, tag, defs) : null;

@@ -164,2 +189,3 @@ str += openTag(tag, renderer.attributes(mdef.attr, item), style);

str += closeTag(tag);
if (href) str += closeTag('a');
}

@@ -166,0 +192,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc