text: (function(){var c,e,a,h,d=[].slice,f=function(j,k){return function(){return j.apply(k,arguments)}},g={}.hasOwnProperty,b=function(m,k){for(var j in k){if(g.call(k,j)){m[j]=k[j]}}function l(){this.constructor=m}l.prototype=k.prototype;m.prototype=new l();m.__super__=k.prototype;return m},i=[].indexOf||function(m){for(var k=0,j=this.length;k<j;k++){if(k in this&&this[k]===m){return k}}return -1};e=window.Morris={};c=jQuery;e.EventEmitter=(function(){function j(){}j.prototype.on=function(k,l){if(this.handlers==null){this.handlers={}}if(this.handlers[k]==null){this.handlers[k]=[]}this.handlers[k].push(l);return this};j.prototype.fire=function(){var n,o,m,q,l,p,k;m=arguments[0],n=2<=arguments.length?d.call(arguments,1):[];if((this.handlers!=null)&&(this.handlers[m]!=null)){p=this.handlers[m];k=[];for(q=0,l=p.length;q<l;q++){o=p[q];k.push(o.apply(null,n))}return k}};return j})();e.commas=function(l){var m,k,j,n;if(l!=null){j=l<0?"-":"";m=Math.abs(l);k=Math.floor(m).toFixed(0);j+=k.replace(/(?=(?:\d{3})+$)(?!^)/g,",");n=m.toString();if(n.length>k.length){j+=n.slice(k.length)}return j}else{return"-"}};e.pad2=function(j){return(j<10?"0":"")+j};e.Grid=(function(k){b(j,k);function j(l){this.resizeHandler=f(this.resizeHandler,this);var m=this;if(typeof l.element==="string"){this.el=c(document.getElementById(l.element))}else{this.el=c(l.element)}if((this.el==null)||this.el.length===0){throw new Error("Graph container element not found")}if(this.el.css("position")==="static"){this.el.css("position","relative")}this.options=c.extend({},this.gridDefaults,this.defaults||{},l);if(typeof this.options.units==="string"){this.options.postUnits=l.units}this.raphael=new Raphael(this.el[0]);this.elementWidth=null;this.elementHeight=null;this.dirty=false;this.selectFrom=null;if(this.init){this.init()}this.setData(this.options.data);this.el.bind("mousemove",function(o){var r,s,p,q,n;s=m.el.offset();n=o.pageX-s.left;if(m.selectFrom){r=m.data[m.hitTest(Math.min(n,m.selectFrom))]._x;p=m.data[m.hitTest(Math.max(n,m.selectFrom))]._x;q=p-r;return m.selectionRect.attr({x:r,width:q})}else{return m.fire("hovermove",n,o.pageY-s.top)}});this.el.bind("mouseleave",function(n){if(m.selectFrom){m.selectionRect.hide();m.selectFrom=null}return m.fire("hoverout")});this.el.bind("touchstart touchmove touchend",function(n){var o,p;p=n.originalEvent.touches[0]||n.originalEvent.changedTouches[0];o=m.el.offset();return m.fire("hovermove",p.pageX-o.left,p.pageY-o.top)});this.el.bind("click",function(n){var o;o=m.el.offset();return m.fire("gridclick",n.pageX-o.left,n.pageY-o.top)});if(this.options.rangeSelect){this.selectionRect=this.raphael.rect(0,0,0,this.el.innerHeight()).attr({fill:this.options.rangeSelectColor,stroke:false}).toBack().hide();this.el.bind("mousedown",function(n){var o;o=m.el.offset();return m.startRange(n.pageX-o.left)});this.el.bind("mouseup",function(n){var o;o=m.el.offset();m.endRange(n.pageX-o.left);return m.fire("hovermove",n.pageX-o.left,n.pageY-o.top)})}if(this.options.resize){c(window).bind("resize",function(n){if(m.timeoutId!=null){window.clearTimeout(m.timeoutId)}return m.timeoutId=window.setTimeout(m.resizeHandler,100)})}this.el.css("-webkit-tap-highlight-color","rgba(0,0,0,0)");if(this.postInit){this.postInit()}}j.prototype.gridDefaults={dateFormat:null,axes:true,grid:true,gridLineColor:"#aaa",gridStrokeWidth:0.5,gridTextColor:"#888",gridTextSize:12,gridTextFamily:"sans-serif",gridTextWeight:"normal",hideHover:false,yLabelFormat:null,xLabelAngle:0,numLines:5,padding:25,parseTime:true,postUnits:"",preUnits:"",ymax:"auto",ymin:"auto 0",goals:[],goalStrokeWidth:1,goalLineColors:["#666633","#999966","#cc6666","#663333"],events:[],eventStrokeWidth:1,eventLineColors:["#005a04","#ccffbb","#3a5f0b","#005502"],rangeSelect:null,rangeSelectColor:"#eef",resize:false};j.prototype.setData=function(p,A){var r,z,q,u,B,s,C,m,w,v,n,l,x,t,o;if(A==null){A=true}this.options.data=p;if((p==null)||p.length===0){this.data=[];this.raphael.clear();if(this.hover!=null){this.hover.hide()}return}l=this.cumulative?0:null;x=this.cumulative?0:null;if(this.options.goals.length>0){B=Math.min.apply(Math,this.options.goals);u=Math.max.apply(Math,this.options.goals);x=x!=null?Math.min(x,B):B;l=l!=null?Math.max(l,u):u}this.data=(function(){var E,D,y;y=[];for(q=E=0,D=p.length;E<D;q=++E){C=p[q];s={src:C};s.label=C[this.options.xkey];if(this.options.parseTime){s.x=e.parseDate(s.label);if(this.options.dateFormat){s.label=this.options.dateFormat(s.x)}else{if(typeof s.label==="number"){s.label=new Date(s.label).toString()}}}else{s.x=q;if(this.options.xLabelFormat){s.label=this.options.xLabelFormat(s)}}w=0;s.y=(function(){var H,F,I,G;I=this.options.ykeys;G=[];for(z=H=0,F=I.length;H<F;z=++H){n=I[z];t=C[n];if(typeof t==="string"){t=parseFloat(t)}if((t!=null)&&typeof t!=="number"){t=null}if(t!=null){if(this.cumulative){w+=t}else{if(l!=null){l=Math.max(t,l);x=Math.min(t,x)}else{l=x=t}}}if(this.cumulative&&(w!=null)){l=Math.max(w,l);x=Math.min(w,x)}G.push(t)}return G}).call(this);y.push(s)}return y}).call(this);if(this.options.parseTime){this.data=this.data.sort(function(D,y){return(D.x>y.x)-(y.x>D.x)})}this.xmin=this.data[0].x;this.xmax=this.data[this.data.length-1].x;this.events=[];if(this.options.events.length>0){if(this.options.parseTime){this.events=(function(){var F,D,E,y;E=this.options.events;y=[];for(F=0,D=E.length;F<D;F++){r=E[F];y.push(e.parseDate(r))}return y}).call(this)}else{this.events=this.options.events}this.xmax=Math.max(this.xmax,Math.max.apply(Math,this.events));this.xmin=Math.min(this.xmin,Math.min.apply(Math,this.events))}if(this.xmin===this.xmax){this.xmin-=1;this.xmax+=1}this.ymin=this.yboundary("min",x);this.ymax=this.yboundary("max",l);if(this.ymin===this.ymax){if(x){this.ymin-=1}this.ymax+=1}if(((o=this.options.axes)===true||o==="both"||o==="y")||this.options.grid===true){if(this.options.ymax===this.gridDefaults.ymax&&this.options.ymin===this.gridDefaults.ymin){this.grid=this.autoGridLines(this.ymin,this.ymax,this.options.numLines);this.ymin=Math.min(this.ymin,this.grid[0]);this.ymax=Math.max(this.ymax,this.grid[this.grid.length-1])}else{m=(this.ymax-this.ymin)/(this.options.numLines-1);this.grid=(function(){var E,y,F,D;D=[];for(v=E=y=this.ymin,F=this.ymax;m>0?E<=F:E>=F;v=E+=m){D.push(v)}return D}).call(this)}}this.dirty=true;if(A){return this.redraw()}};j.prototype.yboundary=function(o,m){var n,l;n=this.options["y"+o];if(typeof n==="string"){if(n.slice(0,4)==="auto"){if(n.length>5){l=parseInt(n.slice(5),10);if(m==null){return l}return Math[o](m,l)}else{if(m!=null){return m}else{return 0}}}else{return parseInt(n,10)}}else{return n}};j.prototype.autoGridLines=function(u,m,r){var v,p,l,o,t,n,s,q,w;t=m-u;w=Math.floor(Math.log(t)/Math.log(10));s=Math.pow(10,w);p=Math.floor(u/s)*s;v=Math.ceil(m/s)*s;n=(v-p)/(r-1);if(s===1&&n>1&&Math.ceil(n)!==n){n=Math.ceil(n);v=p+n*(r-1)}if(p<0&&v>0){p=Math.floor(u/n)*n;v=Math.ceil(m/n)*n}if(n<1){o=Math.floor(Math.log(n)/Math.log(10));l=(function(){var y,x;x=[];for(q=y=p;n>0?y<=v:y>=v;q=y+=n){x.push(parseFloat(q.toFixed(1-o)))}return x})()}else{l=(function(){var y,x;x=[];for(q=y=p;n>0?y<=v:y>=v;q=y+=n){x.push(q)}return x})()}return l};j.prototype._calc=function(){var s,r,p,o,m,n,q,l;m=this.el.width();p=this.el.height();if(this.elementWidth!==m||this.elementHeight!==p||this.dirty){this.elementWidth=m;this.elementHeight=p;this.dirty=false;this.left=this.options.padding;this.right=this.elementWidth-this.options.padding;this.top=this.options.padding;this.bottom=this.elementHeight-this.options.padding;if((q=this.options.axes)===true||q==="both"||q==="y"){n=(function(){var w,v,t,u;t=this.grid;u=[];for(w=0,v=t.length;w<v;w++){r=t[w];u.push(this.measureText(this.yAxisFormat(r)).width)}return u}).call(this);this.left+=Math.max.apply(Math,n)}if((l=this.options.axes)===true||l==="both"||l==="x"){s=(function(){var u,v,t;t=[];for(o=u=0,v=this.data.length;0<=v?u<v:u>v;o=0<=v?++u:--u){t.push(this.measureText(this.data[o].text,-this.options.xLabelAngle).height)}return t}).call(this);this.bottom-=Math.max.apply(Math,s)}this.width=Math.max(1,this.right-this.left);this.height=Math.max(1,this.bottom-this.top);this.dx=this.width/(this.xmax-this.xmin);this.dy=this.height/(this.ymax-this.ymin);if(this.calc){return this.calc()}}};j.prototype.transY=function(l){return this.bottom-(l-this.ymin)*this.dy};j.prototype.transX=function(l){if(this.data.length===1){return(this.left+this.right)/2}else{return this.left+(l-this.xmin)*this.dx}};j.prototype.redraw=function(){this.raphael.clear();this._calc();this.drawGrid();this.drawGoals();this.drawEvents();if(this.draw){return this.draw()}};j.prototype.measureText=function(o,n){var l,m;if(n==null){n=0}m=this.raphael.text(100,100,o).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).rotate(n);l=m.getBBox();m.remove();return l};j.prototype.yAxisFormat=function(l){return this.yLabelFormat(l)};j.prototype.yLabelFormat=function(l){if(typeof this.options.yLabelFormat==="function"){return this.options.yLabelFormat(l)}else{return""+this.options.preUnits+(e.commas(l))+this.options.postUnits}};j.prototype.drawGrid=function(){var o,s,q,n,p,l,r,m;if(this.options.grid===false&&((p=this.options.axes)!==true&&p!=="both"&&p!=="y")){return}l=this.grid;m=[];for(q=0,n=l.length;q<n;q++){o=l[q];s=this.transY(o);if((r=this.options.axes)===true||r==="both"||r==="y"){this.drawYAxisLabel(this.left-this.options.padding/2,s,this.yAxisFormat(o))}if(this.options.grid){m.push(this.drawGridLine("M"+this.left+","+s+"H"+(this.left+this.width)))}else{m.push(void 0)}}return m};j.prototype.drawGoals=function(){var n,o,p,r,m,q,l;q=this.options.goals;l=[];for(p=r=0,m=q.length;r<m;p=++r){o=q[p];n=this.options.goalLineColors[p%this.options.goalLineColors.length];l.push(this.drawGoal(o,n))}return l};j.prototype.drawEvents=function(){var n,p,o,r,m,q,l;q=this.events;l=[];for(o=r=0,m=q.length;r<m;o=++r){p=q[o];n=this.options.eventLineColors[o%this.options.eventLineColors.length];l.push(this.drawEvent(p,n))}return l};j.prototype.drawGoal=function(m,l){return this.raphael.path("M"+this.left+","+(this.transY(m))+"H"+this.right).attr("stroke",l).attr("stroke-width",this.options.goalStrokeWidth)};j.prototype.drawEvent=function(m,l){return this.raphael.path("M"+(this.transX(m))+","+this.bottom+"V"+this.top).attr("stroke",l).attr("stroke-width",this.options.eventStrokeWidth)};j.prototype.drawYAxisLabel=function(n,l,m){return this.raphael.text(n,l,m).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor).attr("text-anchor","end")};j.prototype.drawGridLine=function(l){return this.raphael.path(l).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth)};j.prototype.startRange=function(l){this.hover.hide();this.selectFrom=l;return this.selectionRect.attr({x:l,width:0}).show()};j.prototype.endRange=function(l){var m,n;if(this.selectFrom){n=Math.min(this.selectFrom,l);m=Math.max(this.selectFrom,l);this.options.rangeSelect.call(this.el,{start:this.data[this.hitTest(n)].x,end:this.data[this.hitTest(m)].x});return this.selectFrom=null}};j.prototype.resizeHandler=function(){this.timeoutId=null;this.raphael.setSize(this.el.width(),this.el.height());return this.redraw()};return j})(e.EventEmitter);e.parseDate=function(v){var x,w,k,u,t,A,s,l,j,z,y;if(typeof v==="number"){return v}w=v.match(/^(\d+) Q(\d)$/);u=v.match(/^(\d+)-(\d+)$/);t=v.match(/^(\d+)-(\d+)-(\d+)$/);s=v.match(/^(\d+) W(\d+)$/);l=v.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/);j=v.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/);if(w){return new Date(parseInt(w[1],10),parseInt(w[2],10)*3-1,1).getTime()}else{if(u){return new Date(parseInt(u[1],10),parseInt(u[2],10)-1,1).getTime()}else{if(t){return new Date(parseInt(t[1],10),parseInt(t[2],10)-1,parseInt(t[3],10)).getTime()}else{if(s){z=new Date(parseInt(s[1],10),0,1);if(z.getDay()!==4){z.setMonth(0,1+((4-z.getDay())+7)%7)}return z.getTime()+parseInt(s[2],10)*604800000}else{if(l){if(!l[6]){return new Date(parseInt(l[1],10),parseInt(l[2],10)-1,parseInt(l[3],10),parseInt(l[4],10),parseInt(l[5],10)).getTime()}else{A=0;if(l[6]!=="Z"){A=parseInt(l[8],10)*60+parseInt(l[9],10);if(l[7]==="+"){A=0-A}}return Date.UTC(parseInt(l[1],10),parseInt(l[2],10)-1,parseInt(l[3],10),parseInt(l[4],10),parseInt(l[5],10)+A)}}else{if(j){y=parseFloat(j[6]);x=Math.floor(y);k=Math.round((y-x)*1000);if(!j[8]){return new Date(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10),x,k).getTime()}else{A=0;if(j[8]!=="Z"){A=parseInt(j[10],10)*60+parseInt(j[11],10);if(j[9]==="+"){A=0-A}}return Date.UTC(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10)+A,x,k)}}else{return new Date(parseInt(v,10),0,1).getTime()}}}}}}};e.Hover=(function(){j.defaults={"class":"morris-hover morris-default-style"};function j(k){if(k==null){k={}}this.options=c.extend({},e.Hover.defaults,k);this.el=c("<div class='"+this.options["class"]+"'></div>");this.el.hide();this.options.parent.append(this.el)}j.prototype.update=function(l,k,m){if(!l){return this.hide()}else{this.html(l);this.show();return this.moveTo(k,m)}};j.prototype.html=function(k){return this.el.html(k)};j.prototype.moveTo=function(l,r){var k,o,q,m,n,p;n=this.options.parent.innerWidth();m=this.options.parent.innerHeight();o=this.el.outerWidth();k=this.el.outerHeight();q=Math.min(Math.max(0,l-o/2),n-o);if(r!=null){p=r-k-10;if(p<0){p=r+10;if(p+k>m){p=m/2-k/2}}}else{p=m/2-k/2}return this.el.css({left:q+"px",top:parseInt(p)+"px"})};j.prototype.show=function(){return this.el.show()};j.prototype.hide=function(){return this.el.hide()};return j})();e.Line=(function(j){b(k,j);function k(l){this.hilight=f(this.hilight,this);this.onHoverOut=f(this.onHoverOut,this);this.onHoverMove=f(this.onHoverMove,this);this.onGridClick=f(this.onGridClick,this);if(!(this instanceof e.Line)){return new e.Line(l)}k.__super__.constructor.call(this,l)}k.prototype.init=function(){if(this.options.hideHover!=="always"){this.hover=new e.Hover({parent:this.el});this.on("hovermove",this.onHoverMove);this.on("hoverout",this.onHoverOut);return this.on("gridclick",this.onGridClick)}};k.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],pointStrokeWidths:[1],pointStrokeColors:["#ffffff"],pointFillColors:[],smooth:true,xLabels:"auto",xLabelFormat:null,xLabelMargin:24,hideHover:false};k.prototype.calc=function(){this.calcPoints();return this.generatePaths()};k.prototype.calcPoints=function(){var p,q,o,m,n,l;n=this.data;l=[];for(o=0,m=n.length;o<m;o++){p=n[o];p._x=this.transX(p.x);p._y=(function(){var u,s,r,t;r=p.y;t=[];for(u=0,s=r.length;u<s;u++){q=r[u];if(q!=null){t.push(this.transY(q))}else{t.push(q)}}return t}).call(this);l.push(p._ymax=Math.min.apply(Math,[this.bottom].concat((function(){var u,s,r,t;r=p._y;t=[];for(u=0,s=r.length;u<s;u++){q=r[u];if(q!=null){t.push(q)}}return t})())))}return l};k.prototype.hitTest=function(l){var n,o,q,m,p;if(this.data.length===0){return null}p=this.data.slice(1);for(n=q=0,m=p.length;q<m;n=++q){o=p[n];if(l<(o._x+this.data[n]._x)/2){break}}return n};k.prototype.onGridClick=function(l,n){var m;m=this.hitTest(l);return this.fire("click",m,this.data[m].src,l,n)};k.prototype.onHoverMove=function(l,n){var m;m=this.hitTest(l);return this.displayHoverForRow(m)};k.prototype.onHoverOut=function(){if(this.options.hideHover!==false){return this.displayHoverForRow(null)}};k.prototype.displayHoverForRow=function(l){var m;if(l!=null){(m=this.hover).update.apply(m,this.hoverContentForRow(l));return this.hilight(l)}else{this.hover.hide();return this.hilight()}};k.prototype.hoverContentForRow=function(n){var o,m,r,s,q,l,p;r=this.data[n];o="<div class='morris-hover-row-label'>"+r.label+"</div>";p=r.y;for(m=q=0,l=p.length;q<l;m=++q){s=p[m];o+="<div class='morris-hover-point' style='color: "+(this.colorFor(r,m,"label"))+"'>\n  "+this.options.labels[m]+":\n  "+(this.yLabelFormat(s))+"\n</div>"}if(typeof this.options.hoverCallback==="function"){o=this.options.hoverCallback(n,this.options,o,r.src)}return[o,r._x,r._ymax]};k.prototype.generatePaths=function(){var o,m,n,l;return this.paths=(function(){var s,r,p,q;q=[];for(m=s=0,r=this.options.ykeys.length;0<=r?s<r:s>r;m=0<=r?++s:--s){l=typeof this.options.smooth==="boolean"?this.options.smooth:(p=this.options.ykeys[m],i.call(this.options.smooth,p)>=0);o=(function(){var v,t,w,u;w=this.data;u=[];for(v=0,t=w.length;v<t;v++){n=w[v];if(n._y[m]!==void 0){u.push({x:n._x,y:n._y[m]})}}return u}).call(this);if(o.length>1){q.push(e.Line.createPath(o,l,this.bottom))}else{q.push(null)}}return q}).call(this)};k.prototype.draw=function(){var l;if((l=this.options.axes)===true||l==="both"||l==="x"){this.drawXAxis()}this.drawSeries();if(this.options.hideHover===false){return this.displayHoverForRow(this.data.length-1)}};k.prototype.drawXAxis=function(){var u,o,r,m,t,w,n,q,v,p,s=this;n=this.bottom+this.options.padding/2;t=null;m=null;u=function(z,l){var x,y,A,C,B;x=s.drawXAxisLabel(s.transX(l),n,z);B=x.getBBox();x.transform("r"+(-s.options.xLabelAngle));y=x.getBBox();x.transform("t0,"+(y.height/2)+"...");if(s.options.xLabelAngle!==0){C=-0.5*B.width*Math.cos(s.options.xLabelAngle*Math.PI/180);x.transform("t"+C+",0...")}y=x.getBBox();if(((t==null)||t>=y.x+y.width||(m!=null)&&m>=y.x)&&y.x>=0&&(y.x+y.width)<s.el.width()){if(s.options.xLabelAngle!==0){A=1.25*s.options.gridTextSize/Math.sin(s.options.xLabelAngle*Math.PI/180);m=y.x-A}return t=y.x-s.options.xLabelMargin}else{return x.remove()}};if(this.options.parseTime){if(this.data.length===1&&this.options.xLabels==="auto"){r=[[this.data[0].label,this.data[0].x]]}else{r=e.labelSeries(this.xmin,this.xmax,this.width,this.options.xLabels,this.options.xLabelFormat)}}else{r=(function(){var z,x,y,l;y=this.data;l=[];for(z=0,x=y.length;z<x;z++){w=y[z];l.push([w.label,w.x])}return l}).call(this)}r.reverse();p=[];for(q=0,v=r.length;q<v;q++){o=r[q];p.push(u(o[0],o[1]))}return p};k.prototype.drawSeries=function(){var n,q,o,p,l,m;this.seriesPoints=[];for(n=q=p=this.options.ykeys.length-1;p<=0?q<=0:q>=0;n=p<=0?++q:--q){this._drawLineFor(n)}m=[];for(n=o=l=this.options.ykeys.length-1;l<=0?o<=0:o>=0;n=l<=0?++o:--o){m.push(this._drawPointFor(n))}return m};k.prototype._drawPointFor=function(n){var q,r,p,m,o,l;this.seriesPoints[n]=[];o=this.data;l=[];for(p=0,m=o.length;p<m;p++){r=o[p];q=null;if(r._y[n]!=null){q=this.drawLinePoint(r._x,r._y[n],this.colorFor(r,n,"point"),n)}l.push(this.seriesPoints[n].push(q))}return l};k.prototype._drawLineFor=function(l){var m;m=this.paths[l];if(m!==null){return this.drawLinePath(m,this.colorFor(null,l,"line"),l)}};k.createPath=function(z,n,l){var u,t,v,s,p,A,B,q,o,m,y,w,r,x;B="";if(n){v=e.Line.gradients(z)}q={y:null};for(s=r=0,x=z.length;r<x;s=++r){u=z[s];if(u.y!=null){if(q.y!=null){if(n){t=v[s];A=v[s-1];p=(u.x-q.x)/4;o=q.x+p;y=Math.min(l,q.y+p*A);m=u.x-p;w=Math.min(l,u.y-p*t);B+="C"+o+","+y+","+m+","+w+","+u.x+","+u.y}else{B+="L"+u.x+","+u.y}}else{if(!n||(v[s]!=null)){B+="M"+u.x+","+u.y}}}q=u}return B};k.gradients=function(r){var q,t,o,p,l,n,s,m;t=function(v,u){return(v.y-u.y)/(v.x-u.x)};m=[];for(o=n=0,s=r.length;n<s;o=++n){q=r[o];if(q.y!=null){p=r[o+1]||{y:null};l=r[o-1]||{y:null};if((l.y!=null)&&(p.y!=null)){m.push(t(l,p))}else{if(l.y!=null){m.push(t(l,q))}else{if(p.y!=null){m.push(t(q,p))}else{m.push(null)}}}}else{m.push(null)}}return m};k.prototype.hilight=function(m){var n,q,o,p,l;if(this.prevHilight!==null&&this.prevHilight!==m){for(n=q=0,p=this.seriesPoints.length-1;0<=p?q<=p:q>=p;n=0<=p?++q:--q){if(this.seriesPoints[n][this.prevHilight]){this.seriesPoints[n][this.prevHilight].animate(this.pointShrinkSeries(n))}}}if(m!==null&&this.prevHilight!==m){for(n=o=0,l=this.seriesPoints.length-1;0<=l?o<=l:o>=l;n=0<=l?++o:--o){if(this.seriesPoints[n][m]){this.seriesPoints[n][m].animate(this.pointGrowSeries(n))}}}return this.prevHilight=m};k.prototype.colorFor=function(n,m,l){if(typeof this.options.lineColors==="function"){return this.options.lineColors.call(this,n,m,l)}else{if(l==="point"){return this.options.pointFillColors[m%this.options.pointFillColors.length]||this.options.lineColors[m%this.options.lineColors.length]}else{return this.options.lineColors[m%this.options.lineColors.length]}}};k.prototype.drawXAxisLabel=function(n,l,m){return this.raphael.text(n,l,m).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)};k.prototype.drawLinePath=function(m,l,n){return this.raphael.path(m).attr("stroke",l).attr("stroke-width",this.lineWidthForSeries(n))};k.prototype.drawLinePoint=function(o,m,l,n){return this.raphael.circle(o,m,this.pointSizeForSeries(n)).attr("fill",l).attr("stroke-width",this.pointStrokeWidthForSeries(n)).attr("stroke",this.pointStrokeColorForSeries(n))};k.prototype.pointStrokeWidthForSeries=function(l){return this.options.pointStrokeWidths[l%this.options.pointStrokeWidths.length]};k.prototype.pointStrokeColorForSeries=function(l){return this.options.pointStrokeColors[l%this.options.pointStrokeColors.length]};k.prototype.lineWidthForSeries=function(l){if(this.options.lineWidth instanceof Array){return this.options.lineWidth[l%this.options.lineWidth.length]}else{return this.options.lineWidth}};k.prototype.pointSizeForSeries=function(l){if(this.options.pointSize instanceof Array){return this.options.pointSize[l%this.options.pointSize.length]}else{return this.options.pointSize}};k.prototype.pointGrowSeries=function(l){return Raphael.animation({r:this.pointSizeForSeries(l)+3},25,"linear")};k.prototype.pointShrinkSeries=function(l){return Raphael.animation({r:this.pointSizeForSeries(l)},25,"linear")};return k})(e.Grid);e.labelSeries=function(m,u,q,j,y){var r,l,w,k,p,A,x,z,n,v,o;w=200*(u-m)/q;l=new Date(m);x=e.LABEL_SPECS[j];if(x===void 0){o=e.AUTO_LABEL_ORDER;for(n=0,v=o.length;n<v;n++){k=o[n];A=e.LABEL_SPECS[k];if(w>=A.span){x=A;break}}}if(x===void 0){x=e.LABEL_SPECS.second}if(y){x=c.extend({},x,{fmt:y})}r=x.start(l);p=[];while((z=r.getTime())<=u){if(z>=m){p.push([x.fmt(r),z])}x.incr(r)}return p};a=function(j){return{span:j*60*1000,start:function(k){return new Date(k.getFullYear(),k.getMonth(),k.getDate(),k.getHours())},fmt:function(k){return""+(e.pad2(k.getHours()))+":"+(e.pad2(k.getMinutes()))},incr:function(k){return k.setUTCMinutes(k.getUTCMinutes()+j)}}};h=function(j){return{span:j*1000,start:function(k){return new Date(k.getFullYear(),k.getMonth(),k.getDate(),k.getHours(),k.getMinutes())},fmt:function(k){return""+(e.pad2(k.getHours()))+":"+(e.pad2(k.getMinutes()))+":"+(e.pad2(k.getSeconds()))},incr:function(k){return k.setUTCSeconds(k.getUTCSeconds()+j)}}};e.LABEL_SPECS={decade:{span:172800000000,start:function(j){return new Date(j.getFullYear()-j.getFullYear()%10,0,1)},fmt:function(j){return""+(j.getFullYear())},incr:function(j){return j.setFullYear(j.getFullYear()+10)}},year:{span:17280000000,start:function(j){return new Date(j.getFullYear(),0,1)},fmt:function(j){return""+(j.getFullYear())},incr:function(j){return j.setFullYear(j.getFullYear()+1)}},month:{span:2419200000,start:function(j){return new Date(j.getFullYear(),j.getMonth(),1)},fmt:function(j){return""+(j.getFullYear())+"-"+(e.pad2(j.getMonth()+1))},incr:function(j){return j.setMonth(j.getMonth()+1)}},week:{span:604800000,start:function(j){return new Date(j.getFullYear(),j.getMonth(),j.getDate())},fmt:function(j){return""+(j.getFullYear())+"-"+(e.pad2(j.getMonth()+1))+"-"+(e.pad2(j.getDate()))},incr:function(j){return j.setDate(j.getDate()+7)}},day:{span:86400000,start:function(j){return new Date(j.getFullYear(),j.getMonth(),j.getDate())},fmt:function(j){return""+(j.getFullYear())+"-"+(e.pad2(j.getMonth()+1))+"-"+(e.pad2(j.getDate()))},incr:function(j){return j.setDate(j.getDate()+1)}},hour:a(60),"30min":a(30),"15min":a(15),"10min":a(10),"5min":a(5),minute:a(1),"30sec":h(30),"15sec":h(15),"10sec":h(10),"5sec":h(5),second:h(1)};e.AUTO_LABEL_ORDER=["decade","year","month","week","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"];e.Area=(function(l){var j;b(k,l);j={fillOpacity:"auto",behaveLikeLine:false};function k(n){var m;if(!(this instanceof e.Area)){return new e.Area(n)}m=c.extend({},j,n);this.cumulative=!m.behaveLikeLine;if(m.fillOpacity==="auto"){m.fillOpacity=m.behaveLikeLine?0.8:1}k.__super__.constructor.call(this,m)}k.prototype.calcPoints=function(){var r,o,s,q,n,p,m;p=this.data;m=[];for(q=0,n=p.length;q<n;q++){r=p[q];r._x=this.transX(r.x);o=0;r._y=(function(){var w,u,t,v;t=r.y;v=[];for(w=0,u=t.length;w<u;w++){s=t[w];if(this.options.behaveLikeLine){v.push(this.transY(s))}else{o+=s||0;v.push(this.transY(o))}}return v}).call(this);m.push(r._ymax=Math.max.apply(Math,r._y))}return m};k.prototype.drawSeries=function(){var u,v,s,q,n,w,t,r,p,o,m;this.seriesPoints=[];if(this.options.behaveLikeLine){v=(function(){p=[];for(var y=0,x=this.options.ykeys.length-1;0<=x?y<=x:y>=x;0<=x?y++:y--){p.push(y)}return p}).apply(this)}else{v=(function(){o=[];for(var x=r=this.options.ykeys.length-1;r<=0?x<=0:x>=0;r<=0?x++:x--){o.push(x)}return o}).apply(this)}m=[];for(n=0,w=v.length;n<w;n++){u=v[n];this._drawFillFor(u);this._drawLineFor(u);m.push(this._drawPointFor(u))}return m};k.prototype._drawFillFor=function(m){var n;n=this.paths[m];if(n!==null){n=n+("L"+(this.transX(this.xmax))+","+this.bottom+"L"+(this.transX(this.xmin))+","+this.bottom+"Z");return this.drawFilledPath(n,this.fillForSeries(m))}};k.prototype.fillForSeries=function(n){var m;m=Raphael.rgb2hsl(this.colorFor(this.data[n],n,"line"));return Raphael.hsl(m.h,this.options.behaveLikeLine?m.s*0.9:m.s*0.75,Math.min(0.98,this.options.behaveLikeLine?m.l*1.2:m.l*1.25))};k.prototype.drawFilledPath=function(n,m){return this.raphael.path(n).attr("fill",m).attr("fill-opacity",this.options.fillOpacity).attr("stroke","none")};return k})(e.Line);e.Bar=(function(k){b(j,k);function j(l){this.onHoverOut=f(this.onHoverOut,this);this.onHoverMove=f(this.onHoverMove,this);this.onGridClick=f(this.onGridClick,this);if(!(this instanceof e.Bar)){return new e.Bar(l)}j.__super__.constructor.call(this,c.extend({},l,{parseTime:false}))}j.prototype.init=function(){this.cumulative=this.options.stacked;if(this.options.hideHover!=="always"){this.hover=new e.Hover({parent:this.el});this.on("hovermove",this.onHoverMove);this.on("hoverout",this.onHoverOut);return this.on("gridclick",this.onGridClick)}};j.prototype.defaults={barSizeRatio:0.75,barGap:3,barColors:["#0b62a4","#7a92a3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],barOpacity:1,barRadius:[0,0,0,0],xLabelMargin:50};j.prototype.calc=function(){var l;this.calcBars();if(this.options.hideHover===false){return(l=this.hover).update.apply(l,this.hoverContentForRow(this.data.length-1))}};j.prototype.calcBars=function(){var l,q,r,p,n,o,m;o=this.data;m=[];for(l=p=0,n=o.length;p<n;l=++p){q=o[l];q._x=this.left+this.width*(l+0.5)/this.data.length;m.push(q._y=(function(){var v,t,s,u;s=q.y;u=[];for(v=0,t=s.length;v<t;v++){r=s[v];if(r!=null){u.push(this.transY(r))}else{u.push(null)}}return u}).call(this))}return m};j.prototype.draw=function(){var l;if((l=this.options.axes)===true||l==="both"||l==="x"){this.drawXAxis()}return this.drawSeries()};j.prototype.drawXAxis=function(){var s,v,w,o,q,l,t,x,u,m,p,r,n;m=this.bottom+(this.options.xAxisLabelTopPadding||this.options.padding/2);t=null;l=null;n=[];for(s=p=0,r=this.data.length;0<=r?p<r:p>r;s=0<=r?++p:--p){x=this.data[this.data.length-1-s];v=this.drawXAxisLabel(x._x,m,x.label);u=v.getBBox();v.transform("r"+(-this.options.xLabelAngle));w=v.getBBox();v.transform("t0,"+(w.height/2)+"...");if(this.options.xLabelAngle!==0){q=-0.5*u.width*Math.cos(this.options.xLabelAngle*Math.PI/180);v.transform("t"+q+",0...")}if(((t==null)||t>=w.x+w.width||(l!=null)&&l>=w.x)&&w.x>=0&&(w.x+w.width)<this.el.width()){if(this.options.xLabelAngle!==0){o=1.25*this.options.gridTextSize/Math.sin(this.options.xLabelAngle*Math.PI/180);l=w.x-o}n.push(t=w.x-this.options.xLabelMargin)}else{n.push(v.remove())}}return n};j.prototype.drawSeries=function(){var z,l,q,v,t,o,m,r,y,u,x,p,s,n,w;q=this.width/this.options.data.length;r=this.options.stacked?1:this.options.ykeys.length;z=(q*this.options.barSizeRatio-this.options.barGap*(r-1))/r;if(this.options.barSize){z=Math.min(z,this.options.barSize)}p=q-z*r-this.options.barGap*(r-1);m=p/2;w=this.ymin<=0&&this.ymax>=0?this.transY(0):null;return this.bars=(function(){var D,B,C,A;C=this.data;A=[];for(v=D=0,B=C.length;D<B;v=++D){y=C[v];t=0;A.push((function(){var H,F,E,G;E=y._y;G=[];for(u=H=0,F=E.length;H<F;u=++H){n=E[u];if(n!==null){if(w){s=Math.min(n,w);l=Math.max(n,w)}else{s=n;l=this.bottom}o=this.left+v*q+m;if(!this.options.stacked){o+=u*(z+this.options.barGap)}x=l-s;if(this.options.verticalGridCondition&&this.options.verticalGridCondition(y.x)){this.drawBar(this.left+v*q,this.top,q,Math.abs(this.top-this.bottom),this.options.verticalGridColor,this.options.verticalGridOpacity,this.options.barRadius)}if(this.options.stacked){s-=t}this.drawBar(o,s,z,x,this.colorFor(y,u,"bar"),this.options.barOpacity,this.options.barRadius);G.push(t+=x)}else{G.push(null)}}return G}).call(this))}return A}).call(this)};j.prototype.colorFor=function(p,o,m){var n,l;if(typeof this.options.barColors==="function"){n={x:p.x,y:p.y[o],label:p.label};l={index:o,key:this.options.ykeys[o],label:this.options.labels[o]};return this.options.barColors.call(this,n,l,m)}else{return this.options.barColors[o%this.options.barColors.length]}};j.prototype.hitTest=function(l){if(this.data.length===0){return null}l=Math.max(Math.min(l,this.right),this.left);return Math.min(this.data.length-1,Math.floor((l-this.left)/(this.width/this.data.length)))};j.prototype.onGridClick=function(l,n){var m;m=this.hitTest(l);return this.fire("click",m,this.data[m].src,l,n)};j.prototype.onHoverMove=function(l,o){var m,n;m=this.hitTest(l);return(n=this.hover).update.apply(n,this.hoverContentForRow(m))};j.prototype.onHoverOut=function(){if(this.options.hideHover!==false){return this.hover.hide()}};j.prototype.hoverContentForRow=function(o){var p,m,t,s,q,l,r,n;t=this.data[o];p="<div class='morris-hover-row-label'>"+t.label+"</div>";n=t.y;for(m=l=0,r=n.length;l<r;m=++l){q=n[m];p+="<div class='morris-hover-point' style='color: "+(this.colorFor(t,m,"label"))+"'>\n  "+this.options.labels[m]+":\n  "+(this.yLabelFormat(q))+"\n</div>"}if(typeof this.options.hoverCallback==="function"){p=this.options.hoverCallback(o,this.options,p,t.src)}s=this.left+(o+0.5)*this.width/this.data.length;return[p,s]};j.prototype.drawXAxisLabel=function(o,m,n){var l;return l=this.raphael.text(o,m,n).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)};j.prototype.drawBar=function(o,m,l,s,n,r,q){var p,t;p=Math.max.apply(Math,q);if(p===0||p>s){t=this.raphael.rect(o,m,l,s)}else{t=this.raphael.path(this.roundedRect(o,m,l,s,q))}return t.attr("fill",n).attr("fill-opacity",r).attr("stroke","none")};j.prototype.roundedRect=function(l,p,m,n,o){if(o==null){o=[0,0,0,0]}return["M",l,o[0]+p,"Q",l,p,l+o[0],p,"L",l+m-o[1],p,"Q",l+m,p,l+m,p+o[1],"L",l+m,p+n-o[2],"Q",l+m,p+n,l+m-o[2],p+n,"L",l+o[3],p+n,"Q",l,p+n,l,p+n-o[3],"Z"]};return j})(e.Grid);e.Donut=(function(k){b(j,k);j.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],backgroundColor:"#FFFFFF",labelColor:"#000000",formatter:e.commas,resize:false};function j(l){this.resizeHandler=f(this.resizeHandler,this);this.select=f(this.select,this);this.click=f(this.click,this);var m=this;if(!(this instanceof e.Donut)){return new e.Donut(l)}this.options=c.extend({},this.defaults,l);if(typeof l.element==="string"){this.el=c(document.getElementById(l.element))}else{this.el=c(l.element)}if(this.el===null||this.el.length===0){throw new Error("Graph placeholder not found.")}if(l.data===void 0||l.data.length===0){return}this.raphael=new Raphael(this.el[0]);if(this.options.resize){c(window).bind("resize",function(n){if(m.timeoutId!=null){window.clearTimeout(m.timeoutId)}return m.timeoutId=window.setTimeout(m.resizeHandler,100)})}this.setData(l.data)}j.prototype.redraw=function(){var z,s,q,E,y,v,t,D,A,F,J,B,x,o,m,l,G,I,H,u,r,p,n;this.raphael.clear();s=this.el.width()/2;q=this.el.height()/2;x=(Math.min(s,q)-10)/3;J=0;u=this.values;for(o=0,G=u.length;o<G;o++){B=u[o];J+=B}D=5/(2*x);z=1.9999*Math.PI-D*this.data.length;v=0;y=0;this.segments=[];r=this.values;for(E=m=0,I=r.length;m<I;E=++m){B=r[E];A=v+D+z*(B/J);F=new e.DonutSegment(s,q,x*2,x,v,A,this.data[E].color||this.options.colors[y%this.options.colors.length],this.options.backgroundColor,y,this.raphael);F.render();this.segments.push(F);F.on("hover",this.select);F.on("click",this.click);v=A;y+=1}this.text1=this.drawEmptyDonutLabel(s,q-10,this.options.labelColor,15,800);this.text2=this.drawEmptyDonutLabel(s,q+10,this.options.labelColor,14);t=Math.max.apply(Math,this.values);y=0;p=this.values;n=[];for(l=0,H=p.length;l<H;l++){B=p[l];if(B===t){this.select(y);break}n.push(y+=1)}return n};j.prototype.setData=function(l){var m;this.data=l;this.values=(function(){var q,o,p,n;p=this.data;n=[];for(q=0,o=p.length;q<o;q++){m=p[q];n.push(parseFloat(m.value))}return n}).call(this);return this.redraw()};j.prototype.click=function(l){return this.fire("click",l,this.data[l])};j.prototype.select=function(l){var r,n,o,q,m,p;p=this.segments;for(q=0,m=p.length;q<m;q++){n=p[q];n.deselect()}o=this.segments[l];o.select();r=this.data[l];return this.setLabels(r.label,this.options.formatter(r.value,r))};j.prototype.setLabels=function(p,o){var u,s,r,t,q,l,m,n;u=(Math.min(this.el.width()/2,this.el.height()/2)-10)*2/3;t=1.8*u;r=u/2;s=u/3;this.text1.attr({text:p,transform:""});q=this.text1.getBBox();l=Math.min(t/q.width,r/q.height);this.text1.attr({transform:"S"+l+","+l+","+(q.x+q.width/2)+","+(q.y+q.height)});this.text2.attr({text:o,transform:""});m=this.text2.getBBox();n=Math.min(t/m.width,s/m.height);return this.text2.attr({transform:"S"+n+","+n+","+(m.x+m.width/2)+","+m.y})};j.prototype.drawEmptyDonutLabel=function(q,n,m,o,l){var p;p=this.raphael.text(q,n,"").attr("font-size",o).attr("fill",m);if(l!=null){p.attr("font-weight",l)}return p};j.prototype.resizeHandler=function(){this.timeoutId=null;this.raphael.setSize(this.el.width(),this.el.height());return this.redraw()};return j})(e.EventEmitter);e.DonutSegment=(function(k){b(j,k);function j(n,l,u,s,r,q,m,p,o,t){this.cx=n;this.cy=l;this.inner=u;this.outer=s;this.color=m;this.backgroundColor=p;this.index=o;this.raphael=t;this.deselect=f(this.deselect,this);this.select=f(this.select,this);this.sin_p0=Math.sin(r);this.cos_p0=Math.cos(r);this.sin_p1=Math.sin(q);this.cos_p1=Math.cos(q);this.is_long=(q-r)>Math.PI?1:0;this.path=this.calcSegment(this.inner+3,this.inner+this.outer-5);this.selectedPath=this.calcSegment(this.inner+3,this.inner+this.outer);this.hilight=this.calcArc(this.inner)}j.prototype.calcArcPoints=function(l){return[this.cx+l*this.sin_p0,this.cy+l*this.cos_p0,this.cx+l*this.sin_p1,this.cy+l*this.cos_p1]};j.prototype.calcSegment=function(m,l){var w,v,s,r,o,n,u,t,q,p;q=this.calcArcPoints(m),w=q[0],s=q[1],v=q[2],r=q[3];p=this.calcArcPoints(l),o=p[0],u=p[1],n=p[2],t=p[3];return("M"+w+","+s)+("A"+m+","+m+",0,"+this.is_long+",0,"+v+","+r)+("L"+n+","+t)+("A"+l+","+l+",0,"+this.is_long+",1,"+o+","+u)+"Z"};j.prototype.calcArc=function(p){var m,l,o,n,q;q=this.calcArcPoints(p),m=q[0],o=q[1],l=q[2],n=q[3];return("M"+m+","+o)+("A"+p+","+p+",0,"+this.is_long+",0,"+l+","+n)};j.prototype.render=function(){var l=this;this.arc=this.drawDonutArc(this.hilight,this.color);return this.seg=this.drawDonutSegment(this.path,this.color,this.backgroundColor,function(){return l.fire("hover",l.index)},function(){return l.fire("click",l.index)})};j.prototype.drawDonutArc=function(m,l){return this.raphael.path(m).attr({stroke:l,"stroke-width":2,opacity:0})};j.prototype.drawDonutSegment=function(o,p,n,l,m){return this.raphael.path(o).attr({fill:p,stroke:n,"stroke-width":3}).hover(l).click(m)};j.prototype.select=function(){if(!this.selected){this.seg.animate({path:this.selectedPath},150,"<>");this.arc.animate({opacity:1},150,"<>");return this.selected=true}};j.prototype.deselect=function(){if(this.selected){this.seg.animate({path:this.path},150,"<>");this.arc.animate({opacity:0},150,"<>");return this.selected=false}};return j})(e.EventEmitter)}).call(this);