text: (function(){Sai={};var q;Sai.util={};if(Sai.data==null)Sai.data={};if((q=Sai.data).map==null)q.map={};if((q=Raphael.fn).sai==null)q.sai={};Sai.util.round=function(k,e){return parseFloat((Math.round(k/e)*e).toFixed(Math.max(0,Math.ceil(-1*Math.log(e)/Math.LN10))))};Sai.util.sumArray=function(k){var e,a,b,c;b=a=0;for(c=k.length;b<c;b++){e=k[b];if(typeof e==="number")a+=e}return a};Sai.util.num_abbrev=function(k,e,a){var b,c,d,f;if(e==null)e=2;if(a==null)a=1;if(typeof k==="number"){c=["k","m","b","t"];
  for(b=c.length-1;b>=0;b+=-1){f=3*(b+1);d=Math.pow(10,f);if(a>f)return k;if(Math.abs(k)>=d)return parseFloat((k/d).toFixed(a))+c[b]}return String(parseFloat(k.toFixed(e)))}return k};Sai.util.num_pretty=function(k){var e;if(!(isNaN(parseFloat(k))||!String(k).match(/^[-+]?\d+(\.\d+)?$/))){k=String(k).split(".");for(e=/(\d+)(\d{3})/;e.test(k[0]);)k[0]=k[0].replace(e,"$1,$2");return k[0]+(k.length>1?parseFloat("0."+k[1]).toFixed(2).slice(1):"")}};Sai.util.infoSetters=function(k,e){return[function(){return k(e)},
  function(){return k()}]};Sai.util.transformCoords=function(k,e){var a;if(e.getScreenCTM){a=e.createSVGPoint();a.x=k.clientX;a.y=k.clientY;a=a.matrixTransform(e.getScreenCTM().inverse());if(navigator.userAgent.toLowerCase().indexOf("chrome")!==-1||navigator.userAgent.toLowerCase().indexOf("safari")!==-1){a.x+=document.body.scrollLeft;a.y+=document.body.scrollTop}return{x:a.x,y:a.y}}else return{x:k.x,y:k.y}};Sai.util.multiplyColor=function(k,e,a,b){if(b==null)b=0;e=b+(1-b)*e;b=Raphael.getRGB(k);if(a){k=
  b.r*e;a=b.g*e;e=b.b*e}else{k=b.r+(255-b.r)*(1-e);a=b.g+(255-b.g)*(1-e);e=b.b+(255-b.b)*(1-e)}return{r:Math.max(k,0),g:Math.max(a,0),b:Math.max(e,0),str:"rgb("+k+", "+a+", "+e+")"}};Sai.util.colerp=function(k,e,a){k=Raphael.getRGB(k);e=Raphael.getRGB(e);return"rgb("+(e.r*a+k.r*(1-a))+", "+(e.g*a+k.g*(1-a))+", "+(e.b*a+k.b*(1-a))+")"};Sai.util.reflectColor=function(k,e){var a,b,c,d,f,g,h,i,j;c=Raphael.getRGB(k);f=Raphael.getRGB(e);g={};j=["r","g","b"];h=0;for(i=j.length;h<i;h++){b=j[h];a=c[b];d=f[b];
  g[b]=a===d?a:a>d?d*((255-a)/(255-d)):255-a*(255-d)/d}return"rgb("+g.r+", "+g.g+", "+g.b+")"};Sai.util.setHover=function(k,e,a,b){return k.hover(function(){k.attr(e);return b!=null?typeof b[0]==="function"?b[0](k):void 0:void 0},function(){k.attr(a);return b!=null?typeof b[1]==="function"?b[1](k):void 0:void 0})};Sai.util.n_colors=function(k,e,a){var b,c,d,f;if(e==null)e=function(){return 0};if(a==null)a={saturation:[0.25,0.75],lightness:[0.25,0.75]};b=[];e=e();for(c=0;0<=k?c<k:c>k;0<=k?c++:c--){f=
  a.saturation[0]+Math.random()*(a.saturation[1]-a.saturation[0]);d=a.lightness[0]+Math.random()*(a.lightness[1]-a.lightness[0]);b.push("hsl("+e+", "+f+", "+d+")");e=(e+0.6180339887498948)%1}return b}}).call(this);(function(){var q,k=Array.prototype.indexOf||function(e){for(var a=0,b=this.length;a<b;a++)if(this[a]===e)return a;return-1};if((q=Raphael.fn.sai).prim==null)q.prim={};Raphael.fn.sai.prim.haxis=function(e,a,b,c,d){var f,g,h,i,j,l,n,m,o,p,r,t,v,y,w,s,u,x,z;t=(w=d.ticklens)!=null?w:[5,2];w=(h=d.width)!=null?h:1;h=(p=d.color)!=null?p:"black";m=this.path("M"+a+" "+b+"l"+c+" 0").attr("stroke",h);v=this.set();n=this.set();p=c/25;l=p<e.length?Math.ceil(e.length/p):1;i=c/(e.length-1)*l;u=a;s=-1;r=false;p=
  0;x=null;j=0;for(z=e.length;0<=z?j<z:j>z;j+=l){f=e[j];if(f!=null){g=t[String(f)?0:1];v.push(this.path("M"+u+" "+b+"l0 "+g).attr("stroke",h));if(f!==""){g=this.text(u,b+g+2,Sai.util.num_abbrev(f).substring(0,12));f=g.getBBox();o=g.attr("y")+5;g.attr("y",o);if(x==null||o<x)x=o;n.push(g);g=f.width;p=Math.max(g,p);if(f.x<=s+3)r=true;if(f.x+g>s)s=f.x+g}}u+=i}if(d.title!=null)y=this.text(a+c/2,x+14,d.title).attr({"font-size":"12px","font-weight":"bold"});e=this.set().push(m,v,n,y);if(r){y=n.items;c=0;for(d=
  y.length;c<d;c++){g=y[c];g.rotate(-90);g.translate(0,g.getBBox().width/2-2)}e.push(this.rect(a,b,1,w+p+t[0]).attr("opacity","0"))}return e};Raphael.fn.sai.prim.vaxis=function(e,a,b,c,d){var f,g,h,i,j,l,n,m,o,p,r,t,v,y,w,s,u,x;t=(f=d.ticklens)!=null?f:[5,2];f=(m=d.color)!=null?m:"black";p=(l=d.right)!=null?l:false;m=this.path("M"+a+" "+b+"l0 "+-c).attr("stroke",f);v=this.set();l=this.set();h=c/(e.length-1);u=b;s=null;j=[];n=true;x=0;for(i=e.length;x<i;x++){w=e[x];if(w!==null){r=Sai.util.num_abbrev(w);
  if(k.call(j,r)>=0){n=false;break}j.push(r)}}n||(j=function(){var z,A,B;B=[];z=0;for(A=e.length;z<A;z++){w=e[z];B.push(Sai.util.num_abbrev(w,2,2))}return B}());r=n=0;for(x=e.length;r<x;r++){w=e[r];if(w!==null){i=t[String(w)?0:1];v.push(this.path("M"+a+" "+u+"l"+(p?i:-i)+" 0").attr("stroke",f));o=a+(p?1:-1)*(i+3);i=this.text(o,u,j[n++]);i.attr({"text-anchor":p?"start":"end",fill:f});o+=(p?1:-1)*(i.getBBox().width+8);if(s==null||o<s)s=o;l.push(i)}u-=h}if(d.title!=null){y=this.text(s,b-c/2,d.title).attr({"font-size":"12px",
  "font-weight":"bold"});a=y.getBBox();y.rotate(-90);g=this.rect(a.x+(a.width-a.height)/2,b,a.height,1).attr({opacity:0})}if(g==null)g=null;return this.set().push(this.set().push(m,v,l,g),y)};Raphael.fn.sai.prim.popup=function(e,a,b){var c,d,f,g,h,i;this.set();i=this.set();d=0;f=a+5+5;if("__HEAD__"in b){c=this.text(e,f,b.__HEAD__).attr({fill:"#cfc","font-size":"12","font-weight":"bold"});d=Math.max(d,c.getBBox().width);i.push(c);f+=17}for(h in b)if(h!=="__HEAD__"){g=this.text(e+5,f,h+" = "+b[h]).attr({fill:"white",
  "font-weight":"bold","text-anchor":"start"});d=Math.max(d,g.getBBox().width);f+=10;i.push(g)}b=d+10;this.rect(e,a,b,f-a,5).attr({fill:"black","fill-opacity":".85",stroke:"black"});c!=null&&c.translate(b/2);return i.toFront()};Raphael.fn.sai.prim.legend=function(e,a,b,c,d){var f,g,h,i,j,l,n,m,o;a-=14;j=this.set();h=e;i=a;for(l in c){g=this.text(h+14,i+5,l).attr({fill:(n=d!=null?d[l]:void 0)!=null?n:"black","text-anchor":"start"});f=this.rect(h,i,9,9).attr({fill:(m=c[l])!=null?m:"black",stroke:(o=d!=
  null?d[l]:void 0)!=null?o:"black"});f=this.set().push(g,f);g=f.getBBox().width;if(h-e+15+g>b){j.translate(0,-14);f.translate(e-h,a-i);h=e;i=a}h+=g+15;j.push(f)}return j};Raphael.fn.sai.prim.wrappedText=function(e,a,b,c,d){var f,g,h,i;if(c==null)c="";if(d==null)d=" ";if(typeof spacing==="undefined"||spacing===null)spacing=1;if(!c.match(/^\s*$/)){b=b/6;h=[];for(g=0;g<c.length-1;){f=g+b;i=c.substring(g,f+1);f=f>=c.length?f:i.lastIndexOf(d);h.push(i.substring(0,f));g+=f+1}c=h.join("\n");return this.text(e,
  a+5*h.length,c).attr({"font-family":"Lucida Console","text-anchor":"start"})}};Raphael.fn.sai.prim.info=function(e,a,b,c){var d,f,g,h,i,j;g=this.set();f=e;a=a;for(d in c)if(c[d]!==null){h=d+(d===""?"":": ");h+=typeof c[d]==="string"?c[d]:(j=Sai.util.num_pretty(c[d]))!=null?j:Sai.util.num_abbrev(c[d]);i=6*h.length;if(f-e+i>b){f=e;a+=14}h=this.text(f,a,h).attr({"font-family":"Lucida Console","text-anchor":"start"});f+=i+15;g.push(h)}return g};Raphael.fn.sai.prim.hoverShape=function(e,a,b,c){e=e(this).attr(a);
  Sai.util.setHover(e,c!=null?c[0]:void 0,c!=null?c[1]:void 0,b);return e};Raphael.fn.sai.prim.histogram=function(e,a,b,c,d,f,g,h,i,j,l,n){var m,o,p,r,t,v;if(f==null)f=0;if(g==null)g=1;if(i==null)i=["black","white"];if(j==null)j="white";if(n==null)n=10;t=this.set();t.push(this.rect(e,a-c,b,c).attr({"stroke-width":0,"stroke-opacity":0,fill:j}));c=a-(c-12);a-=5;t.push(this.text(e,a,Sai.util.num_abbrev(f)).attr({"text-anchor":"start"}));t.push(this.text(e+b,a,Sai.util.num_abbrev(g)).attr({"text-anchor":"end"}));
  a-=7;f={};j=g=0;for(v=d.length;j<v;j++){p=d[j];if(p>0){p=Math.min(n-1,Math.floor(n*p/1));if(p in f)f[p]+=1;else f[p]=1;g=Math.max(g,f[p])}}t.push(this.rect(e,a,b,1).attr({fill:"0-"+i[0]+"-"+((o=i[1])!=null?o:i[0]),"stroke-width":0,"stroke-opacity":0}));a-=1;o=b/n;for(m in f){d=(a-c)*(f[m]/g);t.push(i.length===1?r=Sai.util.multiplyColor(i[0],(parseInt(m)+0.5)/n,l,0.2).str:r=Sai.util.colerp(i[0],i[1],(parseInt(m)+0.5)/n),this.rect(e+(parseInt(m)+0.2)*o,a-d,o*0.6,d).attr({fill:r,"stroke-width":l?0:0.35,
  "stroke-opacity":l?0:1,stroke:"#000000"}))}t.push(this.text(e+b/2,c-6,Sai.util.num_abbrev(h)));return t}}).call(this);(function(){Raphael.fn.sai.prim.candlestick=function(q,k,e,a,b,c,d,f,g,h,i){if(d==null)d="black";c%2||c++;c=this.rect(q-c/2,k,c,e-k||1).attr("stroke",d);a=this.path("M"+q+" "+a+"L"+q+" "+k+"M"+q+" "+e+"L"+q+" "+b).attr("stroke",d);c.attr("fill",f?d:"#ffffff");d=this.set().push(c,a);if(g){k=k+(e-k)/2;Sai.util.setHover(d,{scale:"1.5,1.5,"+q+","+k,"fill-opacity":0.5},{scale:"1.0,1.0,"+q+","+k,"fill-opacity":1},i)}return d}}).call(this);(function(){Raphael.fn.sai.prim.radiusLegendCont=function(q,k,e,a,b,c,d,f){var g;if(c==null)c=0;if(d==null)d=1;if(f==null)f="white";g=this.set();g.push(this.rect(q,k-a,e,a).attr({"stroke-width":0,"stroke-opacity":0,fill:f}));a=k-(a-10);k-=5;g.push(this.text(q,k,Sai.util.num_abbrev(c)).attr({"text-anchor":"start"}));g.push(this.text(q+e,k,Sai.util.num_abbrev(d)).attr({"text-anchor":"end"}));k-=7;g.push(this.rect(q,k,e,1).attr({fill:"#000","stroke-width":0,"stroke-opacity":0}));k-=1;c=Math.min(k-a,
  e/2)/2-6;d=c/2;g.push(this.circle(q+d+3,k-d-3,d));g.push(this.circle(q+e-(c+3),k-c-3,c));g.push(this.text(q+e/2,a-5,Sai.util.num_abbrev(b)));return g}}).call(this);(function(){Raphael.fn.sai.prim.line=function(q,k,e){var a,b,c,d;if(k==null)k="black";if(e==null)e=1;c=0;for(d=q.length;c<d;c++){a=q[c];if(a!=null)if(typeof b!=="undefined"&&b!==null)b+="L"+a[0]+" "+a[1];else b="M"+a[0]+" "+a[1]}return this.path(b).attr({stroke:k,"stroke-width":e})};Raphael.fn.sai.prim.area=function(q,k,e,a){var b,c,d,f,g;if(k==null)k="black";if(e==null)e=1;if(q.length<2)return this.set();f=0;for(g=q.length;f<g;f++){c=q[f];if(c!=null)if(typeof d!=="undefined"&&d!==null){d+="L"+c[0]+
  " "+c[1];b+="L"+c[0]+" "+c[1]}else{d="M"+c[0]+" "+c[1];b="M"+c[0]+" "+c[1]}}for(q=a.length-1;q>=0;q+=-1){c=a[q][0];f=a[q][1];b+="L"+c+","+f}a=this.path(b).attr({fill:k,"stroke-width":0,"stroke-opacity":0,"fill-opacity":0.35});k=this.path(d).attr({stroke:k,"stroke-width":e});return this.set().push(a,k)}}).call(this);(function(){}).call(this);(function(){Raphael.fn.sai.prim.stackedBar=function(q,k,e,a,b,c,d){var f,g,h,i,j,l,n,m,o,p;if(b){j=l=a;m=0;for(o=q.length;m<o;m++){g=q[m];if(j<g[1])j=g[1];if(l>g[1])l=g[1]}o=j-l||1}e*=0.67;m=this.set();l=[a,a];j=function(r){return r<a?1:0};g=0;for(p=q.length;0<=p?g<p:g>p;0<=p?g++:g--)if(q[g]!=null&&q[g][1]!==a){i=j(q[g][1]);h=Math.abs(l[i]-q[g][1]);f=l[i]===a?1:0;n=q[g][1]-(i?0:h-f);l[i]=q[g][1];m.push(f=this.rect(q[g][0]-e/2,n,e,h-f).attr("fill",(k!=null?k[g]:void 0)||"#000000").attr("stroke",(k!=
  null?k[g]:void 0)||"#000000"));if(b){h=100*h/o;i=[d!=null?d[0]:void 0,d!=null?d[1]:void 0];i[0]=function(r,t,v){return function(){v!=null&&typeof v[0]==="function"&&v[0]();return t({"(selected)":Sai.util.num_abbrev(r)+"%"},false)}}(h,c,d);Sai.util.setHover(f,{"fill-opacity":0.75},{"fill-opacity":1},i)}}return m};Raphael.fn.sai.prim.groupedBar=function(q,k,e,a,b,c,d){var f,g,h,i,j,l;f=this.set();c=e/(q.length+1);i=(e-c)/2;h=0;for(j=q.length;0<=j?h<j:h>j;0<=j?h++:h--)if(((l=q[h])!=null?l[0]:void 0)!=
  null){e=Math.min(q[h][1],a);g=Math.max(q[h][1],a)-e-0.5;f.push(this.rect(q[h][0]-i+h*c,e,c-1,g).attr("fill",(k!=null?k[h]:void 0)||"#000000").attr("stroke",(k!=null?k[h]:void 0)||"#000000"))}b&&Sai.util.setHover(f,{"fill-opacity":"0.75"},{"fill-opacity":"1.0"},d);return f}}).call(this);(function(){}).call(this);(function(){Sai.Plot=function(){function q(k,e,a,b,c,d,f,g){this.r=k;this.x=e;this.y=a;this.w=b;this.h=c;this.data=d;this.rawdata=f;this.opts=g!=null?g:{};this.setDenormalizedData();this.set=this.r.set()}q.prototype.setDenormalizedData=function(){var k,e,a;if(this.data instanceof Array)return this.dndata=function(){var b,c,d,f;d=this.data;f=[];b=0;for(c=d.length;b<c;b++){k=d[b];f.push(this.denormalize(k))}return f}.call(this);else{if(this.dndata==null)this.dndata={};a=[];for(e in this.data)a.push(this.dndata[e]=
  function(){var b,c,d,f;d=this.data[e];f=[];b=0;for(c=d.length;b<c;b++){k=d[b];f.push(this.denormalize(k))}return f}.call(this));return a}};q.prototype.denormalize=function(k){if(k instanceof Array)return[this.x+this.w*k[0],this.y-this.h*k[1]]};q.prototype.render=function(){this.set.push(this.r.rect(20,20,20,20).attr("fill","red"),this.r.circle(40,40,10).attr("fill","blue"));return this};q.prototype.getInfoToggle=function(k,e){return[function(){return k(e)},function(){return k()}]};return q}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.CandlestickPlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Plot);e.prototype.render=function(a,b,c,d){var f,g,h,i,j,l;if(b==null)b=5;this.set.remove();f=(a!=null?a.__UP__:void 0)||"black";a=(a!=null?a.__DOWN__:void 0)||"red";g=0;for(l=this.dndata.open.length;0<=
  l?g<l:g>l;0<=l?g++:g--)if(this.dndata.close[g]!=null){j=this.dndata.close[g][1]<this.dndata.open[g][1];h={};for(i in this.rawdata)h[i]=this.rawdata[i][g];this.set.push(this.r.sai.prim.candlestick(this.dndata.open[g][0],j&&this.dndata.close[g][1]||this.dndata.open[g][1],j&&this.dndata.open[g][1]||this.dndata.close[g][1],this.dndata.high[g][1],this.dndata.low[g][1],b||5,g&&this.dndata.close[g-1]!=null&&this.dndata.close[g-1][1]<this.dndata.close[g][1]?a:f,!j,c,d,Sai.util.infoSetters(d,h)))}return this};
  return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)if(q.call(b,d))a[d]=b[d];c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},e=function(a,b){return function(){return a.apply(b,arguments)}};Sai.ScatterPlot=function(){function a(){a.__super__.constructor.apply(this,arguments)}k(a,Sai.Plot);a.prototype.render=function(b,c,d,f,g,h,i){var j,l,n,m,o,p,r,t,v,y,w,s,u,x,z,A,B,D,E,F,G,H,I,J,K,L,M;this.set.remove();for(t in this.dndata){p=
  this.dndata[t].length;break}o=function(C,O,N){return O*N+C*(1-N)};u=e(function(C){return this.x+this.w*((C-this.y)/-this.h)},this);for(n=0;0<=p?n<p:n>p;0<=p?n++:n--){w=u((x=this.dndata[b.x])!=null?x[n][1]:void 0);s=(F=this.dndata[b.y])!=null?F[n][1]:void 0;l=c instanceof Array&&b.color!=null?Sai.util.colerp(c[0],c[1],(G=(H=this.data[b.color])!=null?(I=H[n])!=null?I[1]:void 0:void 0)!=null?G:0):c instanceof Object&&b.color!=null?c[this.rawdata[b.color][n]]:"black";v=g instanceof Array&&b.stroke_color!=
  null?Sai.util.colerp(g[0],g[1],(J=(K=this.data[b.stroke_color])!=null?(L=K[n])!=null?L[1]:void 0:void 0)!=null?J:0):g instanceof Object&&b.stroke_color!=null?g[this.rawdata[b.stroke_color][n]]:"black";r=d instanceof Array&&b.radius!=null?o(d[0],d[1],(M=(z=this.data[b.radius])!=null?(A=z[n])!=null?A[1]:void 0:void 0)!=null?M:0):d instanceof Object&&b.radius!=null?d[this.rawdata[b.radius][n]]:5;y=f instanceof Array&&b.stroke_opacity!=null?o(f[0],f[1],(B=(D=this.data[b.stroke_opacity])!=null?(E=D[n])!=
  null?E[1]:void 0:void 0)!=null?B:0):f instanceof Object&&b.stroke_opacity!=null?f[this.rawdata[b.stroke_opacity][n]]:1;if(h){m={};for(t in this.rawdata)t.match("^__")||(m[t]=this.rawdata[t][n]);m=Sai.util.infoSetters(i,m)}this.set.push(j=this.r.circle(w,s,r).attr({fill:l,"stroke-opacity":y,stroke:v,"fill-opacity":0.8,"stroke-width":2}),h?j.hover(function(C){return function(){C[0]();return this.attr("fill-opacity",0.5)}}(m),function(C){return function(){C[1]();return this.attr("fill-opacity",0.8)}}(m)):
  void 0)}return this};return a}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.LinePlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Plot);e.prototype.setDenormalizedData=function(){var a,b,c,d;e.__super__.setDenormalizedData.apply(this,arguments);d=[];for(a in this.dndata)d.push(this.dndata[a].length===1&&((b=this.dndata[a])!=
  null?(c=b[0])!=null?c[0]:void 0:void 0)===this.x?this.dndata[a].push([this.x+this.w,this.dndata[a][0][1]]):void 0);return d};e.prototype.render=function(a,b){var c;this.set.remove();for(c in this.dndata)c.match("^__")||this.set.push(this.r.sai.prim.line(this.dndata[c],(a!=null?a[c]:void 0)||"black",b||1));return this};return e}();Sai.AreaPlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.LinePlot);e.prototype.render=function(a,b,c,d){var f,g,h,i,j,l,n;this.set.remove();
  f=function(){var m,o,p;p=[];m=0;for(o=d.length;m<o;m++){j=d[m];p.push(this.denormalize(j))}return p}.call(this);for(l in this.dndata)if(!l.match("^__")){h=0;for(n=this.dndata[l].length;0<=n?h<n:h>n;0<=n?h++:h--){g=this.dndata[l][h];if(g!=null)break}for(h=n=this.dndata[l].length-1;n<=0?h<=0:h>=0;n<=0?h++:h--){i=this.dndata[l][h];if(i!=null)break}h=function(){var m,o,p;p=[];m=0;for(o=f.length;m<o;m++){j=f[m];p.push([Math.max(Math.min(i[0],j[0]),g[0]),j[1]])}return p}();this.set.push(this.r.sai.prim.area(this.dndata[l],
  (a!=null?a[l]:void 0)||"black",b||1,h));if(c)f=this.dndata[l]}return this};return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.GeoPlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Plot);e.prototype.getRegionColor=function(a,b,c){var d;return Sai.util.multiplyColor(a[c],Math.max(((d=this.data[c][b])!=null?d[1]:void 0)||0,0),this.opts.fromBlack,this.opts.fromBlack?0:0.2).str};
  e.prototype.getRegionOpacity=function(a,b){var c;return((c=this.data[b][a])!=null?c[1]:void 0)!=null?1:0.15};e.prototype.render=function(a,b,c,d,f,g,h){var i,j,l,n,m,o,p,r,t,v;this.set.remove();l=function(){var y,w,s,u;s=this.rawdata[c];u=[];y=0;for(w=s.length;y<w;y++){m=s[y];u.push(m.toUpperCase())}return u}.call(this);r={};i=0;for(j=l.length;0<=j?i<j:i>j;0<=j?i++:i--)r[l[i]]=i;for(m in b.regions){l=r[m];i=b.regions[m].name;j={region:i!=null?i:m};for(v in this.rawdata)if(v!==c)j[v]=this.rawdata[v][l];
  i=this.getRegionColor(a,l,d);l=this.getRegionOpacity(l,d);j=this.getInfoToggle(h,j);n=b.regions[m].path;t=Math.min(this.w/b.width,this.h/b.height);o=this.x;p=this.y-this.h;this.set.push(this.r.sai.prim.hoverShape(function(y,w,s,u){return function(x){return x.path(y).translate(s,u).scale(w,w,s,u)}}(n,t,o,p),{fill:i,stroke:this.opts.fromBlack?f:"black","stroke-width":0.5,opacity:l},g?[function(y){return function(w){navigator.userAgent.toLowerCase().indexOf("msie")!==-1||navigator.userAgent.toLowerCase().indexOf("opera")!==
  -1||w.toFront();return y[0]()}}(j),j[1]]:null,g?[{"fill-opacity":0.75,"stroke-width":this.opts.fromBlack?0.5:1.5},{"fill-opacity":1,"stroke-width":0.5}]:null))}a=this.set.getBBox();this.set.translate((this.w-a.width)/2,(this.h-a.height)/2);return this};return e}();Sai.ChromaticGeoPlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.GeoPlot);e.prototype.getRegionColor=function(a,b){var c,d,f,g,h,i,j;f=g=d=c=0;for(i in this.data){f++;h=Sai.util.multiplyColor(a[i],Math.max(((j=
  this.data[i][b])!=null?j[1]:void 0)||0,0),this.opts.fromBlack,this.opts.fromBlack?0:0.2);if(this.opts.fromBlack){g+=h.r;d+=h.g;c+=h.b}else{g+=1/h.r;d+=1/h.g;c+=1/h.b}}if(!this.opts.fromBlack){g=f/g;d=f/d;c=f/c}return"rgb("+g+", "+d+", "+c+")"};e.prototype.getRegionOpacity=function(a){var b,c;for(b in this.data)if(((c=this.data[b][a])!=null?c[1]:void 0)!=null)return 1;return 0.15};return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.BarPlot=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Plot);e.prototype.render=function(a,b,c,d,f,g){var h,i,j,l,n,m,o,p,r;this.set.remove();b=this.denormalize([0,b])[1];n=0;i=[];h=a?this.r.sai.prim.stackedBar:this.r.sai.prim.groupedBar;for(r in this.dndata){n=
  Math.max(n,this.dndata[r].length);i.push((c!=null?c[r]:void 0)||"black")}for(j=0;0<=n?j<n:j>n;0<=n?j++:j--){c=[];for(r in this.dndata)c.push(this.dndata[r][j]);l={};for(p in this.rawdata)l[p]=this.rawdata[p][j];if(a){o=m=0;for(r in this.rawdata)if(r!==g)if(!isNaN(this.rawdata[r][j])){m+=Math.abs(this.rawdata[r][j]);o+=this.rawdata[r][j]}l["(magnitude)"]=m}this.set.push(h(c,i,this.w/n,b,d,f,Sai.util.infoSetters(f,l)))}return this};return e}()}).call(this);(function(){}).call(this);(function(){var q=function(e,a){return function(){return e.apply(a,arguments)}},k=Array.prototype.indexOf||function(e){for(var a=0,b=this.length;a<b;a++)if(this[a]===e)return a;return-1};Sai.Chart=function(){function e(a,b,c,d,f,g,h,i){var j;this.r=a;this.x=b;this.y=c;this.w=d;this.h=f;this.__LABELS__=h;this.opts=i!=null?i:{};this.drawInfo=q(this.drawInfo,this);this.getMin=q(this.getMin,this);if((a=this.opts).bgcolor==null)a.bgcolor="white";this.colors=(j=this.opts.colors)!=null?j:this.random_colors(g);
  this.setData(g)}e.prototype.random_colors=function(a){var b,c,d,f;b=0;for(f in a)b++;c=Sai.util.n_colors(b,Math.random);b={};d=0;for(f in a)f.match("^__")||(b[f]=c[d++]);return b};e.prototype.groupsToNullPad=function(){return[]};e.prototype.nonNegativeGroups=function(){return[]};e.prototype.nextSeriesSuffix=function(){var a;this.suffixCtr=((a=this.suffixCtr)!=null?a:0)+1;return"["+this.suffixCtr+"]"};e.prototype.fixSeriesName=function(a){return a+(a.match(/^\s+$/)?this.nextSeriesSuffix():"")};e.prototype.setSemanticRename=
  function(a){var b,c;if(this.semanticRenamePatterns!=null){if(this.semanticRenames==null)this.semanticRenames={};c=[];for(b in this.semanticRenamePatterns)c.push(a.match(this.semanticRenamePatterns[b])?this.semanticRenames[b]=a:void 0);return c}};e.prototype.getBaseline=function(a){a=this.normalizedHeight(0,a!=null?a:"all");return[[0,a],[1,a]]};e.prototype.setData=function(a){var b,c,d,f,g,h,i,j,l,n,m;this.data={};this.renames={};if(function(o){var p;for(p in o)if(o.hasOwnProperty(p))return false;
  return true}(a))this.render=function(){return this.showError("(no data -> empty chart)")};else{for(i in a){for(;;){d=this.fixSeriesName(i);this.setSemanticRename(d);if(d===i||!(d in a))break}this.renames[i]=d;if(a[i]instanceof Array)if(this.__LABELS__===i){this.__LABELS__=d;this.data[d]=function(){var o,p,r,t;r=a[i];t=[];o=0;for(p=r.length;o<p;o++){b=r[o];t.push(String(b))}return t}()}else this.data[d]=function(){var o,p,r,t;r=a[i];t=[];o=0;for(p=r.length;o<p;o++){b=r[o];t.push(typeof b==="string"&&
  b.match(/^( +)?[+-]?[\d,]+(\.\d+)?( +)?$/)&&!isNaN(h=parseFloat(b.replace(/,/g,"")))?h:b)}return t}();else this.data[d]=a[i]}d=this.dataGroups(this.data);g=this.nonNegativeGroups();for(c in d)if(d[c].length>0)if(k.call(g,c)>=0){n=d[c];j=0;for(l=n.length;j<l;j++){i=n[j];if(this.data[i]!=null){f=0;for(m=this.data[i].length;0<=m?f<m:f>m;0<=m?f++:f--)if(this.data[i][f]<0)this.data[i][f]*=-1}}}j=this.groupsToNullPad();f=0;for(g=j.length;f<g;f++){c=j[f];if(c in d){n=d[c];c=0;for(l=n.length;c<l;c++){i=n[c];
  this.nullPad(i)}}}return this.normalize(this.data)}};e.prototype.nullPad=function(a){if(a in this.data)return this.data[a]=[null].concat(this.data[a].concat([null]))};e.prototype.caresAbout=function(a){return!(a.match("^__")||a===this.__LABELS__)};e.prototype.dataGroups=function(a){var b;return{all:function(){var c;c=[];for(b in a)this.caresAbout(b)&&c.push(b);return c}.call(this),__META__:function(){var c;c=[];for(b in a)if(b.match("^__")||b===this.__LABELS__)c.push(b);return c}.call(this)}};e.prototype.getYAxisVals=
  function(a,b,c){var d,f,g;if(c==null)c=false;if(!(typeof a==="number"&&typeof b==="number"))return[a,b];if(a===b)return[0,b,b*2];for(f=1;(b-a)*f<10;)f*=10;a*=f;b*=f;g=Math.floor(d=Math.log(b-a)/Math.LN10-0.4);g=Math.pow(10,g);if(d%1>0.7&&!c)g*=4;else if(d%1>0.35&&!c)g*=2;d=Sai.util.round(a-(c?g/2.1:g/1.75),g);if(d<0&&0<=a)d=0;a=Sai.util.round(b+(c?g/2.1:g/1.75),g);d/=f;a/=f;g/=f;f=d;for(b=[f];f<a;){f=Sai.util.round(f+g,g);b.push(f)}return b};e.prototype.getMax=function(a,b){var c,d;return Math.max.apply(Math,
  function(){var f,g,h;h=[];f=0;for(g=b.length;f<g;f++){d=b[f];a[d]!=null&&h.push(Math.max.apply(Math,function(){var i,j,l,n;l=a[d];n=[];i=0;for(j=l.length;i<j;i++){c=l[i];c!=null&&typeof c==="number"&&n.push(c)}return n}()))}return h}())};e.prototype.getMin=function(a,b){var c,d;return Math.min.apply(Math,function(){var f,g,h;h=[];f=0;for(g=b.length;f<g;f++){d=b[f];a[d]!=null&&h.push(Math.min.apply(Math,function(){var i,j,l,n;l=a[d];n=[];i=0;for(j=l.length;i<j;i++){c=l[i];if(c!=null&&typeof c==="number"&&
  (!this.opts.ignoreZeroes||c!==0))n.push(c)}return n}.call(this)))}return h}.call(this))};e.prototype.getStackedMax=function(a,b){var c,d,f;if(this.stackedMax==null)this.stackedMax={};this.stackedMax[b]=(f=this.stackedMax[b])!=null?f:Math.max.apply(Math,function(){var g,h;h=[];c=0;for(g=a[this.__LABELS__].length;0<=g?c<g:c>g;0<=g?c++:c--)h.push(Sai.util.sumArray(function(){var i,j,l;l=[];i=0;for(j=b.length;i<j;i++){d=b[i];d!==this.__LABELS__&&a[d][c]>=0&&l.push(a[d][c])}return l}.call(this)));return h}.call(this));
  return this.stackedMax[b]};e.prototype.getStackedMin=function(a,b){var c,d,f;if(this.stackedMin==null)this.stackedMin={};this.stackedMin[b]=(f=this.stackedMin[b])!=null?f:Math.min.apply(Math,function(){var g,h;h=[];c=0;for(g=a[this.__LABELS__].length;0<=g?c<g:c>g;0<=g?c++:c--)h.push(Sai.util.sumArray(function(){var i,j,l;l=[];i=0;for(j=b.length;i<j;i++){d=b[i];d!==this.__LABELS__&&a[d][c]<0&&l.push(a[d][c])}return l}.call(this)));return h}.call(this));return this.stackedMin[b]};e.prototype.normalize=
  function(a){var b,c,d,f,g,h,i,j,l,n,m,o,p,r,t,v,y,w;i=this.dataGroups(a);this.ndata={};if(this.opts.stacked!=null)this.stackedNdata={};p=function(s,u,x){if(typeof s==="number")return u===x?1:(s-u)/(x-u);return null};b=function(s,u){var x,z,A;z=0;for(A=u.length;z<A;z++){x=u[z];if(!s(x))return false}return true};g=function(s){var u,x,z;x=0;for(z=s.length;x<z;x++){u=s[x];if(typeof u==="number")return false}return true};w=[];for(h in i)if(!(h.match("^__")||Sai.util.sumArray(function(){var s,u,x,z;x=i[h];
  z=[];s=0;for(u=x.length;s<u;s++){v=x[s];z.push(this.data[v].length)}return z}.call(this))===0||b(g,function(){var s,u,x,z;x=i[h];z=[];s=0;for(u=x.length;s<u;s++){v=x[s];z.push(this.data[v])}return z}.call(this)))){this.ndata[h]={};if(this.opts.stacked!=null){this.stackedNdata[h]={};d={}}o=this.opts.stacked?q(function(s,u){return this.getStackedMin(s,u)},this):this.getMin;n=this.opts.stacked?q(function(s,u){return this.getStackedMax(s,u)},this):this.getMax;m=o(a,i[h]);l=n(a,i[h]);n=this.getYAxisVals(m,
  l);m=n[0];l=n[n.length-1];this.ndata[h].__YVALS__=n;w.push(function(){var s,u,x,z;x=i[h];z=[];s=0;for(u=x.length;s<u;s++){v=x[s];if(a[v]!=null){this.ndata[h][v]=function(){var A,B;B=[];j=0;for(A=a[v].length;0<=A?j<A:j>A;0<=A?j++:j--)B.push(a[v][j]!=null&&(t=p(a[v][j],m,l))!==null?[j/(a[v].length-1||1),t]:null);return B}();z.push(function(){var A,B,D;if(this.opts.stacked!=null){r=p(0,m,l);this.stackedNdata[h][v]=[];D=[];j=0;for(A=a[v].length;0<=A?j<A:j>A;0<=A?j++:j--){f=a[v][j]!=null&&a[v][j]<0?0:
  1;if(d[j]==null)d[j]=[r,r];c=d[j][f];y=[j/(a[v].length-1||1),((B=p(a[v][j],m,l))!=null?B:r)-r+c];this.stackedNdata[h][v].push(y);D.push(y!==null?d[j][f]=y[1]:void 0)}return D}}.call(this))}}return z}.call(this))}return w};e.prototype.addAxes=function(a,b){var c,d,f,g,h,i,j,l,n,m,o,p,r;this.axisWidth=1.5;this.padding.top+=5;for(d=c=this.data[this.__LABELS__].length-1;c<=0?d<=0:d>=0;c<=0?d++:d--)if(this.data[this.__LABELS__][d]!=null){d=this.r.text(0,0,Sai.util.num_abbrev(this.data[this.__LABELS__][d]));
  this.padding.right+=d.getBBox().width/2;d.remove();break}i=this.h-(this.padding.bottom+this.padding.top);c=this.ndata[a[0]]!=null||this.ndata[a[1]]==null;d=this.ndata[a[1]]!=null;if(c){r=this.r.sai.prim.vaxis((g=(l=this.ndata[a[0]])!=null?l.__YVALS__:void 0)!=null?g:[0,"?"],this.x+this.padding.left,this.y-this.padding.bottom,i,{width:this.axisWidth,title:b!=null?b.left:void 0});g=r.items[0].getBBox().width;r.remove()}else g=0;if(d){r=this.r.sai.prim.vaxis((f=(n=this.ndata[a[1]])!=null?n.__YVALS__:
  void 0)!=null?f:[0,"?"],this.x+this.padding.left,this.y-this.padding.bottom,i,{width:this.axisWidth,title:b!=null?b.right:void 0});f=r.getBBox().width;r.remove()}else f=0;this.haxis=this.r.sai.prim.haxis(this.data[this.__LABELS__],this.x+this.padding.left+g,this.y-this.padding.bottom,this.w-this.padding.left-this.padding.right-g-f,{width:this.axisWidth,title:b!=null?b.bottom:void 0});f=this.haxis.getBBox().height;if(isNaN(f))f=1;this.haxis.translate(0,-f);this.padding.bottom+=f;i=this.h-(this.padding.bottom+
  this.padding.top);if(c){this.vaxis=this.r.sai.prim.vaxis((h=(m=this.ndata[a[0]])!=null?m.__YVALS__:void 0)!=null?h:[0,"?"],this.x+this.padding.left,this.y-this.padding.bottom,i,{width:this.axisWidth,title:b!=null?b.left:void 0});h=this.vaxis.items[0].getBBox().width;this.vaxis.translate(h,0);this.padding.left+=h}if(d){this.vaxis_right=this.r.sai.prim.vaxis((o=(p=this.ndata[a[1]])!=null?p.__YVALS__:void 0)!=null?o:[0,"?"],this.w-this.padding.right,this.y-this.padding.bottom,i,{width:this.axisWidth,
  right:true,title:b!=null?b.right:void 0,color:this.ndata[a[0]]!=null?(j=this.colors.__RIGHTAXIS__)!=null?j:"blue":"black"});j=this.vaxis_right.items[0].getBBox().width;this.vaxis_right.translate(-j,0);this.padding.right+=j}this.setPlotCoords();this.axes=this.r.set().push(this.haxis).push(this.vaxis);if(this.everything==null)this.everything=this.r.set();this.everything.push(this.axes);return this.axes};e.prototype.setPlotCoords=function(){var a,b,c,d;this.px=this.x+this.padding.left;this.py=this.y-
  this.padding.bottom;this.pw=this.w-this.padding.left-this.padding.right;this.ph=this.h-this.padding.bottom-this.padding.top;a=(b=this.legend)!=null?b.getBBox():void 0;if((b=this.legend)!=null)b.translate(this.px+this.pw/2-(a.x+a.width/2),0);a=(c=this.histogramLegend)!=null?c.getBBox():void 0;return(d=this.histogramLegend)!=null?d.translate(this.px+this.pw/2-(a.x+a.width/2),0):void 0};e.prototype.drawBG=function(){this.bg=this.r.rect(this.px!=null&&this.px||this.x,this.py!=null&&this.py-this.ph||this.y-
  this.h,this.pw!=null&&this.pw||this.w,this.ph!=null&&this.ph||this.h).attr({fill:this.opts.bgcolor,"stroke-width":0,"stroke-opacity":0}).toBack();if(this.everything==null)this.everything=this.r.set();return this.everything.push(this.bg)};e.prototype.drawFootnote=function(a){var b;if(a==null)a=(b=this.opts.footnote)!=null?b:"";if(!a.match(/^\s*$/)){this.footnote=this.r.sai.prim.wrappedText(this.x+this.padding.left,this.y-this.padding.bottom,this.w,a," ");a=this.footnote.getBBox().height;this.padding.bottom+=
  a+10;this.footnote.translate(0,-a);if(this.everything==null)this.everything=this.r.set();return this.everything.push(this.footnote)}};e.prototype.plotSets=function(){var a,b,c,d,f;b=this.r.set();f=this.plots;c=0;for(d=f.length;c<d;c++){a=f[c];b.push(a.set)}return b};e.prototype.render=function(){var a;if((a=this.everything)!=null)a.remove();a=this.opts.simple?0:5;this.padding={left:a,right:a,top:a,bottom:a};this.plots=[];this.opts.simple&&this.renderPlots!=null?this.renderPlots():this.renderFull();
  this.everything.push(this.plotSets());return this};e.prototype.renderFull=function(){if(this.plot==null)this.plot=new Sai.Plot(this.r);this.plot.render();return this};e.prototype.showError=function(a){var b,c;return this.r.text(this.x+this.padding.left+((b=this.pw)!=null?b:this.w)/2,this.y-this.padding.bottom-((c=this.ph)!=null?c:this.h)/2,a)};e.prototype.setColors=function(a){var b,c;if(this.colors==null)this.colors={};for(b in a){c=this.renames[b];if(c in this.data)this.colors[c]=a[b]}return this};
  e.prototype.setColor=function(a,b){if(this.colors==null)this.colors={};this.colors[this.renames[a]]=b;return this};e.prototype.normalizedHeight=function(a,b){var c,d;if(((c=this.ndata[b])!=null?c.__YVALS__:void 0)!=null){d=this.ndata[b].__YVALS__[0];c=this.ndata[b].__YVALS__[this.ndata[b].__YVALS__.length-1];if(a<d)a=d;else if(a>c)a=c;return(a-d)/(c-d)}};e.prototype.drawGuideline=function(a,b){var c;if(b==null)b="all";if(((c=this.ndata[b])!=null?c.__YVALS__:void 0)!=null){c=this.normalizedHeight(a,
  b);if(this.guidelines==null)this.guidelines=this.r.set();c=new Sai.LinePlot(this.r,this.px,this.py,this.pw,this.ph,{guideline:[[0,c],[1,c]]});c.render({guideline:"#ccc"});this.guidelines.push(c.set);if(this.everything==null)this.everything=this.r.set();return this.everything.push(this.guidelines)}};e.prototype.drawLegend=function(a){var b,c,d,f,g;if(a==null)a=this.colors;if(a){c={};d={};for(b in a)if(b!==this.__LABELS__){c[b]=a[b];d[b]="black";if(((f=this.opts.groups)!=null?f.right:void 0)!=null)if(k.call(this.opts.groups.right,
  b)>=0)d[b]=this.ndata.left!=null?(g=this.colors.__RIGHTAXIS__)!=null?g:"blue":"black"}this.legend=this.r.sai.prim.legend(this.x,this.y-this.padding.bottom,this.w,c,d);a=this.legend.getBBox();if(this.legend.length>0)this.padding.bottom+=a.height+15;this.legend.translate((this.w-a.width)/2,0)}if(this.everything==null)this.everything=this.r.set();return this.everything.push(this.legend)};e.prototype.drawTitle=function(){if(this.opts.title!=null){this.title=this.r.text(this.x+this.w/2,this.y-this.h,this.opts.title).attr({"font-size":20});
  this.title.translate(0,this.title.getBBox().height/2);this.padding.top+=this.title.getBBox().height+5}if(this.everything==null)this.everything=this.r.set();return this.everything.push(this.title)};e.prototype.setupInfoSpace=function(){this.info_y=this.y-this.h+this.padding.top;this.info_x=this.x+this.padding.left;this.info_w=this.w-this.padding.left-this.padding.right;return this.padding.top+=30};e.prototype.drawInfo=function(a,b){var c,d,f;if(b==null)b=true;if(a==null)a=(d=typeof this.default_info===
  "function"?this.default_info():void 0)!=null?d:{};if(b)this.info_data={};this.info&&this.info.remove();for(c in a)c.match("^__")||(this.info_data[c]=(f=a[c])!=null?f:"(no data)");return this.info=this.r.sai.prim.info(this.info_x,this.info_y,this.info_w,this.info_data)};e.prototype.getIndex=function(a){a=Sai.util.transformCoords(a,this.r.canvas).x;return Math.round((this.data[this.__LABELS__].length-1)*(a-this.px)/this.pw)};e.prototype.drawHistogramLegend=function(a,b,c){var d,f,g,h,i,j,l,n,m,o,p,
  r,t,v,y;if(b==null)b=this.colors;this.histogramLegend=this.r.set();i=Math.max(0.1*(this.h-this.padding.bottom-this.padding.top),50);o=Math.min(150,(this.w-this.padding.left-this.padding.right-20)/a.length);j=0;for(r=a.length;0<=r?j<r:j>r;0<=r?j++:j--){m=a[j];g=function(){var w,s;s=[];l=0;for(w=this.ndata[m][m].length;0<=w?l<w:l>w;0<=w?l++:l--)this.ndata[m][m][l]!=null&&s.push(this.ndata[m][m][l][1]);return s}.call(this);if(this.opts.ignoreZeroes)g=function(){var w,s,u;u=[];w=0;for(s=g.length;w<s;w++){f=
  g[w];f!==0&&u.push(f)}return u}();if(((t=this.bounds)!=null?t[m]:void 0)!=null){d=this.bounds[m];h=d[0];d=d[1]}else{h=function(){var w,s,u,x;u=this.data[m];x=[];w=0;for(s=u.length;w<s;w++){p=u[w];if(p!=null&&(!this.opts.ignoreZeroes||p!==0))x.push(p)}return x}.call(this);d=[Math.min.apply(Math,h),Math.max.apply(Math,h)];h=d[0];d=d[1]}d=this.getYAxisVals(h,d,true);h=d[0];n=d[d.length-1];d=b[m];this.histogramLegend.push(h=this.r.sai.prim.histogram(this.x+j*o,this.y-this.padding.bottom,o*0.8,i,g,h,n,
  (v=c!=null?c[j]:void 0)!=null?v:m,typeof d==="object"?[d.__LOW__,d.__HIGH__]:[d],(y=this.opts.bgcolor)!=null?y:"white",this.opts.fromBlack));this.opts.interactive&&this.setupHistogramInteraction(h,m)}this.histogramLegend.translate((this.w-this.padding.left-this.padding.right-this.histogramLegend.getBBox().width)/2,0);return this.padding.bottom+=i+5};e.prototype.setupHistogramInteraction=function(){return null};return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)if(q.call(b,d))a[d]=b[d];c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},e=function(a,b){return function(){return a.apply(b,arguments)}};Sai.StockChart=function(){function a(){a.__super__.constructor.apply(this,arguments)}k(a,Sai.Chart);a.prototype.semanticRenamePatterns={open:/^open$/i,close:/^close$/i,high:/^high$/i,low:/^low$/i,volume:/^vol(ume)?$/i};a.prototype.groupsToNullPad=
  function(){return["prices","volume","__META__"]};a.prototype.dataGroups=function(b){var c,d,f,g;c={__META__:[this.__LABELS__]};f=(g=this.semanticRenames.volume)!=null?g:"volume";if(f in this.data)c.volume=[f];for(d in b)if(this.caresAbout(d)&&d!==this.__LABELS__&&d!==f){if(c.prices==null)c.prices=[];c.prices.push(d)}return c};a.prototype.nonNegativeGroups=function(){return["volume"]};a.prototype.renderPlots=function(){var b,c,d,f,g,h,i,j,l,n;this.px==null&&this.setPlotCoords();g=(c=this.semanticRenames.open)!=
  null?c:"open";c=(d=this.semanticRenames.close)!=null?d:"close";d=(f=this.semanticRenames.high)!=null?f:"high";f=(l=this.semanticRenames.low)!=null?l:"low";l=(h=this.semanticRenames.volume)!=null?h:"volume";if(this.colors==null)this.colors={};if((h=this.colors).__UP__==null)h.__UP__="black";if((h=this.colors).__DOWN__==null)h.__DOWN__="red";if((h=this.colors).__VOL_UP__==null)h.__VOL_UP__="#666666";if((h=this.colors).__VOL_DOWN__==null)h.__VOL_DOWN__="#cc6666";this.drawBG();if(this.ndata.prices!=null&&
  g in this.ndata.prices&&c in this.ndata.prices&&d in this.ndata.prices&&f in this.ndata.prices){this.ndata.prices.__YVALS__[0]<0&&this.drawGuideline(0,"prices");j={up:[],down:[]};h={};for(b in this.ndata.prices)b.match("^__")||b===this.__LABELS__||(h[b]=this.data[b]);if(this.data[l]!=null)h.vol=this.data[l];if("volume"in this.ndata){b=0;for(n=this.ndata.volume[l].length;0<=n?b<n:b>n;0<=n?b++:b--)if(this.ndata.volume[l][b]!==null)if(b&&this.ndata.prices[c][b-1]&&this.ndata.prices[c][b][1]<this.ndata.prices[c][b-
  1][1]){j.down.push(this.ndata.volume[l][b]);j.up.push([this.ndata.volume[l][b][0],0])}else{j.up.push(this.ndata.volume[l][b]);j.down.push([this.ndata.volume[l][b][0],0])}else{j.up.push([0,0]);j.down.push([0,0])}this.plots.push((new Sai.BarPlot(this.r,this.px,this.py,this.pw,this.ph*0.2,j,h)).render(true,this.normalizedHeight(0,"volume"),{up:this.colors.__VOL_UP__,down:this.colors.__VOL_DOWN__}))}this.plots.push((new Sai.CandlestickPlot(this.r,this.px,this.py,this.pw,this.ph,{open:this.ndata.prices[g],
  close:this.ndata.prices[c],high:this.ndata.prices[d],low:this.ndata.prices[f]},h)).render(this.colors,Math.min(5,this.pw/this.ndata.prices[g].length-2)));b={};for(i in this.ndata.prices)i===g||i===c||i===d||i===f||i.match("^__")||i===this.__LABELS__||(b[i]=this.ndata.prices[i]);return this.plots.push((new Sai.LinePlot(this.r,this.px,this.py,this.pw,this.ph,b)).render(this.colors))}else this.showError("This chart requires data series named\nopen, close, high, and low.\n \nOnce you add series with these names, the chart will display.")};
  a.prototype.renderFull=function(){var b,c,d,f,g,h,i,j,l,n,m;this.drawTitle();this.setupInfoSpace();this.drawFootnote();d=(c=this.semanticRenames.open)!=null?c:"open";c=(g=this.semanticRenames.close)!=null?g:"close";g=(h=this.semanticRenames.high)!=null?h:"high";h=(b=this.semanticRenames.low)!=null?b:"low";l=(j=this.semanticRenames.volume)!=null?j:"volume";b={};j=false;for(i in this.ndata.prices)if(i!==d&&i!==c&&i!==g&&i!==h&&!(i.match("^__")||i===this.__LABELS__)){b[i]=((n=this.colors)!=null?n[i]:
  void 0)||"black";j=true}j&&this.drawLegend(b);this.addAxes(["prices"]);this.renderPlots();f=this.pw/(this.data[this.__LABELS__].length-1);d=(m=this.colors.__GLOW__)!=null?m:"#DDAA99";this.glow=this.r.rect(this.px-f/2,this.py-this.ph,f,this.ph).attr({fill:"0-"+this.opts.bgcolor+"-"+d+"-"+this.opts.bgcolor,"stroke-width":0,"stroke-opacity":0}).toBack().hide();this.bg.toBack();this.opts.interactive&&this.r.set().push(this.bg,this.plotSets(),this.glow,this.guidelines).mousemove(e(function(o){var p,r,
  t,v,y;o=this.getIndex(o);p={};if(this.data[this.__LABELS__][o]!=null)p[this.__LABELS__]=this.data[this.__LABELS__][o];r=false;for(t in this.ndata.prices)if(!(t.match("^__")||t===this.__LABELS__))if(((v=this.data[t])!=null?v[o]:void 0)!=null){p[t]=this.data[t][o];r=true}if(((y=this.data[l])!=null?y[o]:void 0)!=null){p[l]=this.data[l][o];r=true}this.drawInfo(p);if(r)return this.glow.attr({x:this.px+f*(o-0.5)}).show()},this)).mouseout(e(function(){this.drawInfo({},true);return this.glow.hide()},this));
  return this};return a}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.ScatterChart=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Chart);e.prototype.dataGroups=function(a){var b,c;b={__META__:function(){var d;d=[];for(c in a)if(c.match("^__")||c===this.__LABELS__)d.push(c);return d}.call(this)};for(c in a)c.match("^__")||
  c===this.__LABELS__||(b[c]=[c]);return b};e.prototype.get_colors=function(a){var b,c,d,f;if(a!=null)if(typeof((b=this.data[a])!=null?b[0]:void 0)==="number")return Sai.util.n_colors(2);else{b={};f=this.data[a];c=0;for(d=f.length;c<d;c++){a=f[c];a in b||(b[a]=1)}return this.random_colors(b)}};e.prototype.set_defaults=function(){var a,b,c,d,f;if((a=this.opts).colors==null)a.colors=(c=this.get_colors(this.opts.mappings.color))!=null?c:["black","white"];if((a=this.opts).stroke_opacity==null)a.stroke_opacity=
  [0,1];if((a=this.opts).stroke_colors==null)a.stroke_colors=(d=this.get_colors(this.opts.mappings.stroke_color))!=null?d:["black","black"];return(f=(b=this.opts).radii)!=null?f:b.radii=[4,12]};e.prototype.renderPlots=function(){var a,b;this.px==null&&this.setPlotCoords();this.drawBG();a={};for(b in this.ndata)a[b]=this.ndata[b][b];this.set_defaults();this.plots.push((new Sai.ScatterPlot(this.r,this.px,this.py,this.pw,this.ph,a,this.data)).render(this.opts.mappings,this.opts.colors,this.opts.radii,
  this.opts.stroke_opacity,this.opts.stroke_colors,this.opts.interactive&&!this.opts.simple,this.drawInfo));return this};e.prototype.renderFull=function(){var a,b,c,d,f,g,h,i,j;this.drawTitle();this.setupInfoSpace();this.drawFootnote();this.set_defaults();g=[];d={};f=[];h={};j=this.opts;b=j.colors;i=j.radii;j=j.stroke_colors;if(b instanceof Array){g.push(this.opts.mappings.color);d[this.opts.mappings.color]={__LOW__:b[0],__HIGH__:b[1]};f.push(null)}else{c=true;for(a in b)h[a]=b[a]}if(this.opts.mappings.stroke_color)if(j instanceof
  Array){g.push(this.opts.mappings.stroke_color);d[this.opts.mappings.stroke_color]={__LOW__:j[0],__HIGH__:j[1]};f.push(""+this.opts.mappings.stroke_color+" (stroke)")}else{c=true;for(a in j)h[a]=j[a]}if(i instanceof Array&&this.opts.mappings.radius!=null){a=this.ndata[this.opts.mappings.radius].__YVALS__;this.radiusLegend=this.r.sai.prim.radiusLegendCont(this.x+(this.w-100)/2,this.y-this.padding.bottom,100,55,this.opts.mappings.radius,a[0],a[a.length-1],this.opts.bgcolor);this.padding.bottom+=60}g.length&&
  this.drawHistogramLegend(g,d,f);c&&this.drawLegend(h);this.__LABELS__="__XVALS__";this.data.__XVALS__=this.ndata[this.opts.mappings.x].__YVALS__;this.addAxes([this.opts.mappings.y],{left:this.opts.mappings.y,bottom:this.opts.mappings.x});this.renderPlots();c=this.r.set().push(this.plotSets(),this.bg,this.info,this.footnote,this.histogramLegend,this.radiusLegend,this.legend);this.opts.href&&c.attr({href:this.opts.href,target:"_blank"});return this};e.prototype.setPlotCoords=function(){var a,b,c;e.__super__.setPlotCoords.apply(this,
  arguments);a=(b=this.radiusLegend)!=null?b.getBBox():void 0;return(c=this.radiusLegend)!=null?c.translate(this.px+this.pw/2-(a.x+a.width/2),0):void 0};return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)if(q.call(b,d))a[d]=b[d];c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},e=function(a,b){return function(){return a.apply(b,arguments)}};Sai.LineChart=function(){function a(){a.__super__.constructor.apply(this,arguments)}k(a,Sai.Chart);a.prototype.nonNegativeGroups=function(){return this.opts.stacked?["all","left","right"]:[]};a.prototype.dataGroups=function(){var b,
  c,d,f;b=a.__super__.dataGroups.apply(this,arguments);if(((d=this.opts.groups)!=null?d.left:void 0)!=null&&((f=this.opts.groups)!=null?f.right:void 0)!=null){b.left=function(){var g,h,i,j;i=this.opts.groups.left;j=[];g=0;for(h=i.length;g<h;g++){c=i[g];this.caresAbout(c)&&c in this.data&&j.push(c)}return j}.call(this);b.right=function(){var g,h,i,j;i=this.opts.groups.right;j=[];g=0;for(h=i.length;g<h;g++){c=i[g];this.caresAbout(c)&&c in this.data&&j.push(c)}return j}.call(this)}return b};a.prototype.renderPlots=
  function(){var b,c,d,f,g,h,i,j;this.px==null&&this.setPlotCoords();this.drawBG();d="right"in this.ndata;b=this.opts.stacked!=null?this.stackedNdata:this.ndata;c=this.opts.area?Sai.AreaPlot:Sai.LinePlot;if(d){if(((f=this.ndata.left)!=null?f.__YVALS__[0]:void 0)<0)this.drawGuideline(0,"left");if(((g=this.ndata.right)!=null?g.__YVALS__[0]:void 0)<0)this.drawGuideline(0,"right")}else this.ndata.all.__YVALS__[0]<0&&this.drawGuideline(0,"all");if(d){if(b.left!=null)this.plots.push((new c(this.r,this.px,
  this.py,this.pw,this.ph,b.left)).render(this.colors,(h=this.opts.lineWidth)!=null?h:2,this.opts.stacked,this.getBaseline("left")));if(b.right!=null)return this.plots.push((new c(this.r,this.px,this.py,this.pw,this.ph,b.right)).render(this.colors,(i=this.opts.lineWidth)!=null?i:2,this.opts.stacked,this.getBaseline("right")))}else return this.plots.push((new c(this.r,this.px,this.py,this.pw,this.ph,b.all)).render(this.colors,(j=this.opts.lineWidth)!=null?j:2,this.opts.stacked,this.getBaseline("all")))};
  a.prototype.renderFull=function(){var b,c,d,f;this.drawTitle();this.setupInfoSpace();this.drawFootnote();this.drawLegend();"right"in this.ndata?this.addAxes(["left","right"]):this.addAxes(["all"]);this.renderPlots();this.dots=this.r.set();b=this.r.set().push(this.bg,this.plotSets(),this.dots,this.guidelines);if(this.opts.interactive){for(c in this.ndata.all)if(c!=="__YVALS__")this.dots.push(this.r.circle(0,0,4).attr({fill:(d=(f=this.colors)!=null?f[c]:void 0)!=null?d:"black"}).hide());b.mousemove(e(function(g){var h,
  i,j,l,n,m;i=this.getIndex(g);g={};if(((m=this.data[this.__LABELS__])!=null?m.length:void 0)>i&&i>=0){g[this.__LABELS__]=this.data[this.__LABELS__][i];for(n in this.ndata.all)if(this.data[n]!=null)g[n]=this.data[n][i]}this.drawInfo(g);h=0;m=[];for(n in this.ndata.all)n!=="__YVALS__"&&m.push(function(){var o,p,r,t;r=this.plots;t=[];o=0;for(p=r.length;o<p;o++){j=r[o];if(n in j.dndata){l=j.dndata[n][i];l!=null?this.dots[h].attr({cx:l[0],cy:l[1]}).show().toFront():this.dots[h].hide();t.push(h++)}}return t}.call(this));
  return m},this)).mouseout(e(function(){this.drawInfo({},true);return this.dots.hide()},this))}this.opts.href&&b.attr({href:this.opts.href,target:"_blank"});return this};return a}()}).call(this);(function(){var q=function(a,b){return function(){return a.apply(b,arguments)}},k=Object.prototype.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var d in b)if(k.call(b,d))a[d]=b[d];c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};Sai.GeoChart=function(){function a(){this.renderPlots=q(this.renderPlots,this);a.__super__.constructor.apply(this,arguments)}e(a,Sai.Chart);a.prototype.plotType=Sai.GeoPlot;a.prototype.getMax=function(b){return Math.max.apply(Math,
  b)};a.prototype.getMin=function(b){var c,d;c=b;if(this.opts.ignoreZeroes)c=function(){var f,g,h;h=[];f=0;for(g=c.length;f<g;f++){d=c[f];d!==0&&h.push(d)}return h}();return Math.min.apply(Math,c)};a.prototype.normalize=function(b){var c,d,f,g,h,i,j,l,n,m;this.ndata={};this.bounds={};h={};j={};for(m in b)if(!(m.match("^__")||m===this.__LABELS__))if(b[m]!=null){d=function(){var o,p,r,t;r=b[m];t=[];o=0;for(p=r.length;o<p;o++){c=r[o];c!=null&&t.push(c)}return t}();h[m]=this.getMax(d,m);if(!(typeof l!==
  "undefined"&&l!==null)||h[m]>l)l=h[m];j[m]=this.getMin(d,m);if(!(typeof n!=="undefined"&&n!==null)||j[m]<n)n=j[m]}d=[];for(m in b)if(!(m.match("^__")||m===this.__LABELS__))if(b[m]!=null){if(this.opts.groupedNormalization){g=l;i=n}else{g=h[m];i=j[m]}this.bounds[m]=[i,g];this.ndata[m]={};d.push(this.ndata[m][m]=function(){var o,p;p=[];f=0;for(o=b[m].length;0<=o?f<o:f>o;0<=o?f++:f--)p.push(b[m][f]!=null?[f/(b[m].length-1),(b[m][f]-i)/(g-i)]:null);return p}())}return d};a.prototype.dataGroups=function(b){var c,
  d;c={__META__:function(){var f;f=[];for(d in b)if(d.match("^__")||d===this.__LABELS__)f.push(d);return f}.call(this)};for(d in b)d.match("^__")||d===this.__LABELS__||(c[d]=[d]);return c};a.prototype.setupHistogramInteraction=function(b,c){var d;b.click(q(function(){return this.renderPlots(c)},this));d=this.drawInfo;return Sai.util.setHover(b,{"fill-opacity":0.75},{"fill-opacity":1},[function(f,g){return function(){return f({"Click to display on map":g})}}(d,c),function(f){return function(){return f()}}(d)])};
  a.prototype.renderPlots=function(b){var c,d;this.px==null&&this.setPlotCoords();if((c=this.bg)!=null)c.remove();if((c=this.geoPlot)!=null)c.set.remove();this.drawBG();c={};for(d in this.ndata)c[d]=this.ndata[d][d];this.geoPlot=(new this.plotType(this.r,this.px,this.py,this.pw,this.ph,c,this.data,{fromBlack:this.opts.fromBlack})).render(this.colors||{},this.data.__MAP__,this.__LABELS__,b!=null?b:this.data.__DEFAULT__,this.opts.bgcolor,this.opts.interactive&&!this.opts.simple,this.drawInfo);this.plots.push(this.geoPlot);
  return this};a.prototype.default_info=function(){return{"":this.opts.interactive?"Click histogram below to change map display":""}};a.prototype.renderFull=function(){var b,c;this.drawTitle();this.setupInfoSpace();this.drawFootnote();this.drawHistogramLegend(function(){var d;d=[];for(c in this.data)c.match("^__")||c===this.__LABELS__||d.push(c);return d}.call(this));this.setPlotCoords();this.drawInfo();this.renderPlots();b=this.r.set().push(this.geoPlot.set,this.bg,this.info,this.footnote);this.opts.href&&
  b.attr({href:this.opts.href,target:"_blank"});return this};return a}();Sai.ChromaticGeoChart=function(){function a(){a.__super__.constructor.apply(this,arguments)}e(a,Sai.GeoChart);a.prototype.plotType=Sai.ChromaticGeoPlot;a.prototype.default_info=function(){return{}};a.prototype.setupHistogramInteraction=function(){return false};return a}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.BarChart=function(){function e(){e.__super__.constructor.apply(this,arguments)}k(e,Sai.Chart);e.prototype.getMin=function(){return Math.min(e.__super__.getMin.apply(this,arguments),0)};e.prototype.groupsToNullPad=function(){var a,b;b=[];for(a in this.dataGroups())b.push(a);return b};
  e.prototype.tooMuchData=function(){var a,b,c;b=this.w/3;a=0;for(c in this.data)if(c!==this.__LABELS__){a+=this.data[c].length;if(this.opts.stacked)break}return a>b};e.prototype.renderPlots=function(){var a,b,c,d,f;this.px==null&&this.setPlotCoords();this.drawBG();if(this.tooMuchData()){this.showError("Sorry, the chart isn't wide enough to plot this much data.\n \nPossible solutions include downsampling your data\n (e.g. weekly instead of daily) or using a line chart");return this}if("all"in this.ndata){this.guidelines=
  this.r.set();f=this.ndata.all.__YVALS__.slice(1,this.ndata.all.__YVALS__.length-1);b=0;for(c=f.length;b<c;b++){a=f[b];this.drawGuideline(a)}}a={};c={};c[this.__LABELS__]=this.data[this.__LABELS__];b=this.opts.stacked!=null?this.stackedNdata:this.ndata;for(d in b.all)if(!(d.match("^__")||d===this.__LABELS__)){a[d]=b.all[d];c[d]=this.data[d]}return this.plots.push((new Sai.BarPlot(this.r,this.px,this.py,this.pw,this.ph,a,c)).render(this.opts.stacked!=null,this.normalizedHeight(0,"all"),this.colors,
  this.opts.interactive&&!this.opts.simple,this.drawInfo,this.__LABELS__))};e.prototype.renderFull=function(){var a;this.drawTitle();this.setupInfoSpace();this.drawFootnote();this.drawLegend();this.addAxes(["all"]);this.renderPlots();a=this.r.set().push(this.plotSets(),this.bg,this.guidelines);this.opts.href&&a.attr({href:this.opts.href,target:"_blank"});return this};return e}()}).call(this);(function(){var q=Object.prototype.hasOwnProperty,k=function(e,a){function b(){this.constructor=e}for(var c in a)if(q.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e};Sai.StreamChart=function(){function e(a,b,c,d,f,g,h,i){this.r=a;this.x=b;this.y=c;this.w=d;this.h=f;this.__LABELS__=h;this.opts=i;this.opts.stacked=true;e.__super__.constructor.apply(this,arguments)}k(e,Sai.LineChart);e.prototype.getStackedMax=function(){return e.__super__.getStackedMax.apply(this,
  arguments)/2};e.prototype.getStackedMin=function(a,b){var c,d;c=e.__super__.getStackedMin.apply(this,arguments);d=this.getStackedMax(a,b);return c-d};e.prototype.normalize=function(a){var b,c,d,f,g,h,i,j,l,n;e.__super__.normalize.apply(this,arguments);c=this.dataGroups(this.data);if(this.baselines==null)this.baselines={};n=[];for(b in this.stackedNdata){f=this.normalizedHeight(0,b!=null?b:"all");this.normalizedHeight(this.getStackedMin(a,c[b]),b);this.baselines[b]=[];this.ndata[b].__YVALS__=function(){var m,
  o,p,r;p=this.ndata[b].__YVALS__;r=[];m=0;for(o=p.length;m<o;m++){l=p[m];r.push(Math.abs(l))}return r}.call(this);for(i in this.stackedNdata[b])j=i;n.push(function(){var m,o;o=[];d=0;for(m=this.stackedNdata[b][i].length;0<=m?d<m:d>m;0<=m?d++:d--){g=(this.stackedNdata[b][j][d][1]-f)/2;for(i in this.stackedNdata[b]){h=this.stackedNdata[b][i][d];if(h!=null)h[1]-=g}o.push(this.baselines[b].push([h[0],f-g]))}return o}.call(this))}return n};e.prototype.addAxes=function(a,b){if(b==null)b={};"left"in b||(b.left=
  "magnitude");return e.__super__.addAxes.call(this,a,b)};e.prototype.getBaseline=function(a){return this.baselines[a]};return e}()}).call(this);
  